Sha256: 639d348b2c5b0e1690c790fbf6daa4a619ebcf52a1b675002fdb8b4b99823500

Contents?: true

Size: 1.46 KB

Versions: 77

Compression:

Stored size: 1.46 KB

Contents

const SemVer = require('../classes/semver')
const Range = require('../classes/range')
const gt = require('../functions/gt')

const minVersion = (range, loose) => {
  range = new Range(range, loose)

  let minver = new SemVer('0.0.0')
  if (range.test(minver)) {
    return minver
  }

  minver = new SemVer('0.0.0-0')
  if (range.test(minver)) {
    return minver
  }

  minver = null
  for (let i = 0; i < range.set.length; ++i) {
    const comparators = range.set[i]

    let setMin = null
    comparators.forEach((comparator) => {
      // Clone to avoid manipulating the comparator's semver object.
      const compver = new SemVer(comparator.semver.version)
      switch (comparator.operator) {
        case '>':
          if (compver.prerelease.length === 0) {
            compver.patch++
          } else {
            compver.prerelease.push(0)
          }
          compver.raw = compver.format()
          /* fallthrough */
        case '':
        case '>=':
          if (!setMin || gt(compver, setMin)) {
            setMin = compver
          }
          break
        case '<':
        case '<=':
          /* Ignore maximum versions */
          break
        /* istanbul ignore next */
        default:
          throw new Error(`Unexpected operation: ${comparator.operator}`)
      }
    })
    if (setMin && (!minver || gt(minver, setMin))) {
      minver = setMin
    }
  }

  if (minver && range.test(minver)) {
    return minver
  }

  return null
}
module.exports = minVersion

Version data entries

77 entries across 43 versions & 4 rubygems

Version Path
immosquare-cleaner-0.1.49 node_modules/vue-eslint-parser/node_modules/semver/ranges/min-version.js
immosquare-cleaner-0.1.49 node_modules/semver/ranges/min-version.js
immosquare-cleaner-0.1.49 node_modules/@typescript-eslint/typescript-estree/node_modules/semver/ranges/min-version.js
immosquare-cleaner-0.1.49 node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/utils/node_modules/@typescript-eslint/typescript-estree/node_modules/semver/ranges/min-version.js
immosquare-cleaner-0.1.48 node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/utils/node_modules/@typescript-eslint/typescript-estree/node_modules/semver/ranges/min-version.js
immosquare-cleaner-0.1.48 node_modules/vue-eslint-parser/node_modules/semver/ranges/min-version.js
immosquare-cleaner-0.1.48 node_modules/semver/ranges/min-version.js
immosquare-cleaner-0.1.48 node_modules/@typescript-eslint/typescript-estree/node_modules/semver/ranges/min-version.js
immosquare-cleaner-0.1.48 node_modules/@typescript-eslint/type-utils/node_modules/@typescript-eslint/typescript-estree/node_modules/semver/ranges/min-version.js
immosquare-cleaner-0.1.47 node_modules/semver/ranges/min-version.js
immosquare-cleaner-0.1.46 node_modules/semver/ranges/min-version.js
pcp-server-ruby-sdk-0.0.6 node_modules/semver/ranges/min-version.js
pcp-server-ruby-sdk-0.1.0 node_modules/semver/ranges/min-version.js
immosquare-cleaner-0.1.45 node_modules/semver/ranges/min-version.js
immosquare-cleaner-0.1.42 node_modules/semver/ranges/min-version.js
immosquare-cleaner-0.1.41 node_modules/semver/ranges/min-version.js
immosquare-cleaner-0.1.40 node_modules/semver/ranges/min-version.js
immosquare-cleaner-0.1.39 node_modules/semver/ranges/min-version.js
immosquare-cleaner-0.1.38 node_modules/semver/ranges/min-version.js
immosquare-cleaner-0.1.32 node_modules/jsonc-eslint-parser/node_modules/semver/ranges/min-version.js