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