Sha256: 61bba5b5a7154145ca7f0cb149ee87dca076806ffb22d65a4eca36a2e71b4218

Contents?: true

Size: 1.36 KB

Versions: 25

Compression:

Stored size: 1.36 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]

    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 (!minver || gt(minver, compver)) {
            minver = compver
          }
          break
        case '<':
        case '<=':
          /* Ignore maximum versions */
          break
        /* istanbul ignore next */
        default:
          throw new Error(`Unexpected operation: ${comparator.operator}`)
      }
    })
  }

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

  return null
}
module.exports = minVersion

Version data entries

25 entries across 23 versions & 7 rubygems

Version Path
optimacms-0.1.61 spec/dummy/node_modules/css-loader/node_modules/semver/ranges/min-version.js
optimacms-0.1.61 spec/dummy/node_modules/core-js-compat/node_modules/semver/ranges/min-version.js
disco_app-0.16.1 test/dummy/node_modules/core-js-compat/node_modules/semver/ranges/min-version.js
disco_app-0.15.2 test/dummy/node_modules/core-js-compat/node_modules/semver/ranges/min-version.js
disco_app-0.18.4 test/dummy/node_modules/core-js-compat/node_modules/semver/ranges/min-version.js
disco_app-0.18.1 test/dummy/node_modules/core-js-compat/node_modules/semver/ranges/min-version.js
disco_app-0.12.7.pre.puma.pre.3 test/dummy/node_modules/core-js-compat/node_modules/semver/ranges/min-version.js
disco_app-0.14.0 test/dummy/node_modules/core-js-compat/node_modules/semver/ranges/min-version.js
disco_app-0.13.6.pre.puma.pre.3 test/dummy/node_modules/core-js-compat/node_modules/semver/ranges/min-version.js
tang-0.2.1 spec/tang_app/node_modules/core-js-compat/node_modules/semver/ranges/min-version.js
groonga-client-model-6.0.0 test/apps/rails6.1.3/node_modules/core-js-compat/node_modules/semver/ranges/min-version.js
groonga-client-model-6.0.0 test/apps/rails6.0.3.5/node_modules/core-js-compat/node_modules/semver/ranges/min-version.js
ruby2js-4.0.4 lib/tasks/testrails/node_modules/core-js-compat/node_modules/semver/ranges/min-version.js
ruby2js-4.0.3 lib/tasks/testrails/node_modules/core-js-compat/node_modules/semver/ranges/min-version.js
tang-0.2.0 spec/tang_app/node_modules/core-js-compat/node_modules/semver/ranges/min-version.js
tang-0.1.0 spec/tang_app/node_modules/core-js-compat/node_modules/semver/ranges/min-version.js
tang-0.0.9 spec/tang_app/node_modules/core-js-compat/node_modules/semver/ranges/min-version.js
enju_library-0.3.8 spec/dummy/node_modules/core-js-compat/node_modules/semver/ranges/min-version.js
condenser-0.3 lib/condenser/processors/node_modules/core-js-compat/node_modules/semver/ranges/min-version.js
condenser-0.2 lib/condenser/processors/node_modules/core-js-compat/node_modules/semver/ranges/min-version.js