semver#subset TypeScript Examples

The following examples show how to use semver#subset. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: dependency-version-compare.ts    From eslint-config-kit with MIT License 6 votes vote down vote up
function compare(
  versionOrRange: string,
  target: string,
  sign: '<' | '>'
): boolean {
  if (valid(versionOrRange)) {
    return satisfies(versionOrRange, sign + target)
  }

  if (validRange(versionOrRange)) {
    const matches = satisfies(target, versionOrRange)
    return subset(versionOrRange, sign + target) || (sign === '>' && matches)
  }

  throw new InvalidVersionError()
}