Comparing version 1.1.4 to 2.0.0-alpha
{ | ||
"name": "semver", | ||
"version": "1.1.4", | ||
"version": "2.0.0-alpha", | ||
"description": "The semantic version parser used by npm.", | ||
@@ -12,6 +12,3 @@ "main": "semver.js", | ||
}, | ||
"license": { | ||
"type": "MIT", | ||
"url": "https://github.com/isaacs/semver/raw/master/LICENSE" | ||
}, | ||
"license": "BSD", | ||
"repository": "git://github.com/isaacs/node-semver.git", | ||
@@ -18,0 +15,0 @@ "bin": { |
@@ -36,37 +36,7 @@ semver(1) -- The semantic versioner for npm | ||
A version is the following things, in this order: | ||
A "version" is described by the v2.0.0 specification found at | ||
<http://semver.org/>. | ||
* a number (Major) | ||
* a period | ||
* a number (minor) | ||
* a period | ||
* a number (patch) | ||
* OPTIONAL: a hyphen, followed by a number (build) | ||
* OPTIONAL: a collection of pretty much any non-whitespace characters | ||
(tag) | ||
A leading `"="` or `"v"` character is stripped off and ignored. | ||
## Comparisons | ||
The ordering of versions is done using the following algorithm, given | ||
two versions and asked to find the greater of the two: | ||
* If the majors are numerically different, then take the one | ||
with a bigger major number. `2.3.4 > 1.3.4` | ||
* If the minors are numerically different, then take the one | ||
with the bigger minor number. `2.3.4 > 2.2.4` | ||
* If the patches are numerically different, then take the one with the | ||
bigger patch number. `2.3.4 > 2.3.3` | ||
* If only one of them has a build number, then take the one with the | ||
build number. `2.3.4-0 > 2.3.4` | ||
* If they both have build numbers, and the build numbers are numerically | ||
different, then take the one with the bigger build number. | ||
`2.3.4-10 > 2.3.4-9` | ||
* If only one of them has a tag, then take the one without the tag. | ||
`2.3.4 > 2.3.4-beta` | ||
* If they both have tags, then take the one with the lexicographically | ||
larger tag. `2.3.4-beta > 2.3.4-alpha` | ||
* At this point, they're equal. | ||
## Ranges | ||
@@ -76,11 +46,25 @@ | ||
* `1.2.3` A specific version. When nothing else will do. Note that | ||
build metadata is still ignored, so `1.2.3+build2012` will satisfy | ||
this range. | ||
* `>1.2.3` Greater than a specific version. | ||
* `<1.2.3` Less than | ||
* `1.2.3 - 2.3.4` := `>=1.2.3 <=2.3.4` | ||
* `~1.2.3` := `>=1.2.3 <1.3.0` | ||
* `~1.2` := `>=1.2.0 <1.3.0` | ||
* `~1` := `>=1.0.0 <2.0.0` | ||
* `1.2.x` := `>=1.2.0 <1.3.0` | ||
* `1.x` := `>=1.0.0 <2.0.0` | ||
* `<1.2.3` Less than a specific version. If there is no prerelease | ||
tag on the version range, then no prerelease version will be allowed | ||
either, even though these are technically "less than". | ||
* `>=1.2.3` Greater than or equal to. Note that prerelease versions | ||
are NOT equal to their "normal" equivalents, so `1.2.3-beta` will | ||
not satisfy this range, but `2.3.0-beta` will. | ||
* `<=1.2.3` Less than or equal to. In this case, prerelease versions | ||
ARE allowed, so `1.2.3-beta` would satisfy. | ||
* `1.2.3 - 2.3.4` := `>=1.2.3-0 <=2.3.4-0` | ||
* `~1.2.3` := `>=1.2.3-0 <1.3.0-0` "Reasonably close to 1.2.3". When | ||
using tilde operators, prerelease versions are supported as well, | ||
but a prerelease of the next significant digit will NOT be | ||
satisfactory, so `1.3.0-beta` will not satisfy `~1.2.3`. | ||
* `~1.2` := `>=1.2.0-0 <1.3.0-0` "Any version starting with 1.2" | ||
* `1.2.x` := `>=1.2.0-0 <1.3.0-0` "Any version starting with 1.2" | ||
* `~1` := `>=1.0.0-0 <2.0.0-0` "Any version starting with 1" | ||
* `1.x` := `>=1.0.0-0 <2.0.0-0` "Any version starting with 1" | ||
Ranges can be joined with either a space (which implies "and") or a | ||
@@ -87,0 +71,0 @@ `||` (which implies "or"). |
846
semver.js
@@ -1,158 +0,523 @@ | ||
;(function (exports) { // nothing in here is node-specific. | ||
;(function(exports) { | ||
// See http://semver.org/ | ||
// This implementation is a *hair* less strict in that it allows | ||
// v1.2.3 things, and also tags that don't begin with a char. | ||
// export the class if we are in a Node-like system. | ||
if (typeof module === 'object' && module.exports === exports) | ||
exports = module.exports = SemVer; | ||
var semver = "\\s*[v=]*\\s*([0-9]+)" // major | ||
+ "\\.([0-9]+)" // minor | ||
+ "\\.([0-9]+)" // patch | ||
+ "(-[0-9]+-?)?" // build | ||
+ "([a-zA-Z-+][a-zA-Z0-9-\.:]*)?" // tag | ||
, exprComparator = "^((<|>)?=?)\s*("+semver+")$|^$" | ||
, xRangePlain = "[v=]*([0-9]+|x|X|\\*)" | ||
+ "(?:\\.([0-9]+|x|X|\\*)" | ||
+ "(?:\\.([0-9]+|x|X|\\*)" | ||
+ "([a-zA-Z-][a-zA-Z0-9-\.:]*)?)?)?" | ||
, xRange = "((?:<|>)=?)?\\s*" + xRangePlain | ||
, exprLoneSpermy = "(?:~>?)" | ||
, exprSpermy = exprLoneSpermy + xRange | ||
, expressions = exports.expressions = | ||
{ parse : new RegExp("^\\s*"+semver+"\\s*$") | ||
, parsePackage : new RegExp("^\\s*([^\/]+)[-@](" +semver+")\\s*$") | ||
, parseRange : new RegExp( | ||
"^\\s*(" + semver + ")\\s+-\\s+(" + semver + ")\\s*$") | ||
, validComparator : new RegExp("^"+exprComparator+"$") | ||
, parseXRange : new RegExp("^"+xRange+"$") | ||
, parseSpermy : new RegExp("^"+exprSpermy+"$") | ||
} | ||
var debug; | ||
if (typeof process === 'object' && | ||
process.env && | ||
process.env.NODE_DEBUG && | ||
/\bsemver\b/i.test(process.env.NODE_DEBUG)) | ||
debug = function() { | ||
var args = Array.prototype.slice.call(arguments, 0); | ||
args.unshift('SEMVER'); | ||
console.log.apply(console, args); | ||
}; | ||
else | ||
debug = function() {}; | ||
// Note: this is the semver.org version of the spec that it implements | ||
// Not necessarily the package version of this code. | ||
exports.SEMVER_SPEC_VERSION = '2.0.0'; | ||
Object.getOwnPropertyNames(expressions).forEach(function (i) { | ||
exports[i] = function (str) { | ||
return ("" + (str || "")).match(expressions[i]) | ||
// The actual regexps go on exports.re | ||
var re = exports.re = {}; | ||
var src = exports.src = {}; | ||
// The following Regular Expressions can be used for tokenizing, | ||
// validating, and parsing SemVer version strings. | ||
// ## Numeric Identifier | ||
// A single `0`, or a non-zero digit followed by zero or more digits. | ||
src.numericIdentifier = '0|[1-9]\\d*'; | ||
// ## Non-numeric Identifier | ||
// Zero or more digits, followed by a letter or hyphen, and then zero or | ||
// more letters, digits, or hyphens. | ||
src.nonNumericIdentifier = '\\d*[a-zA-Z-][a-zA-Z0-9-]*'; | ||
// ## Main Version | ||
// Three dot-separated numeric identifiers. | ||
src.mainVersion = '(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)'; | ||
// ## Pre-release Version Identifier | ||
// A numeric identifier, or a non-numeric identifier. | ||
src.prereleaseIdentifier = '(?:0|[1-9]\\d*|\\d*[a-zA-Z-][a-zA-Z0-9-]*)'; | ||
// ## Pre-release Version | ||
// Hyphen, followed by one or more dot-separated pre-release version identifiers. | ||
src.prerelease = '(?:-(' + src.prereleaseIdentifier + | ||
'(?:\\.' + src.prereleaseIdentifier + ')*))'; | ||
src.prereleaseLoose = '(?:-?(' + src.prereleaseIdentifier + | ||
'(?:\\.' + src.prereleaseIdentifier + ')*))'; | ||
// ## Build Metadata Identifier | ||
// Any combination of digits, letters, or hyphens. | ||
src.buildIdentifier = '[0-9A-Za-z-]+'; | ||
// ## Build Metadata | ||
// Plus sign, followed by one or more period-separated build metadata | ||
// identifiers. | ||
src.build = '(?:\\+(' + src.buildIdentifier + | ||
'(?:\\.' + src.buildIdentifier + ')*))'; | ||
// ## Full Version String | ||
// A main version, followed optionally by a pre-release version and | ||
// build metadata. | ||
// Note that the only major, minor, patch, and pre-release sections of | ||
// the version string are capturing groups. The build metadata is not a | ||
// capturing group, because it should not ever be used in version | ||
// comparison. | ||
src.full = '^' + src.mainVersion + | ||
src.prerelease + '?' + | ||
src.build + '?' + | ||
'$'; | ||
// like full, but allows v1.2.3 and =1.2.3, which people do sometimes. | ||
// also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty | ||
// common in the npm registry. | ||
var loose = '[v=\\s]*' + src.mainVersion + | ||
'(?:' + src.prereleaseLoose + ')?' + | ||
'(?:' + src.build + ')?'; | ||
src.loose = '^' + loose + '$'; | ||
src.gtlt = '((?:<|>)?=?)'; | ||
// Something like "2.*" or "1.2.x". | ||
// Note that "x.x" is a valid xRange identifer, meaning "any version" | ||
// Only the first item is strictly required. | ||
src.xRangeIdentifier = src.numericIdentifier + '|x|X|\\*'; | ||
src.xRangePlain = '[v=\\s]*(' + src.xRangeIdentifier + ')' + | ||
'(?:\\.(' + src.xRangeIdentifier + ')' + | ||
'(?:\\.(' + src.xRangeIdentifier + ')' + | ||
'(?:(' + src.prereleaseLoose + ')' + | ||
')?)?)?'; | ||
// >=2.x, for example, means >=2.0.0-0 | ||
// <1.x would be the same as "<1.0.0-0", though. | ||
src.xRange = '^' + src.gtlt + '\\s*' + src.xRangePlain + '$'; | ||
// Tilde ranges. | ||
// Meaning is "reasonably at or greater than" | ||
src.loneTilde = '(?:~>?)'; | ||
src.tildeTrim = src.loneTilde + '\s+'; | ||
var tildeTrimReplace = '$1'; | ||
src.tilde = '^' + src.loneTilde + src.xRangePlain + '$'; | ||
// A simple gt/lt/eq thing, or just "" to indicate "any version" | ||
src.comparator = '^' + src.gtlt + '\\s*(' + loose + ')$|^$'; | ||
// An expression to strip any whitespace between the gtlt and the thing | ||
// it modifies, so that `> 1.2.3` ==> `>1.2.3` | ||
src.comparatorTrim = src.gtlt + | ||
'\\s*(' + loose + '|' + src.xRangePlain + ')'; | ||
// this one has to use the /g flag | ||
re.comparatorTrim = new RegExp(src.comparatorTrim, 'g'); | ||
var comparatorTrimReplace = '$1$2 '; | ||
// Something like `1.2.3 - 1.2.4` | ||
src.hyphenRange = '^\\s*(' + loose + ')' + | ||
'\\s+-\\s+' + | ||
'(' + loose + ')' + | ||
'\\s*$'; | ||
var hyphenReplace = '>=$1 <=$7'; | ||
// Star ranges basically just allow anything at all. | ||
src.star = '(<|>)?=?\\s*\\*'; | ||
for (var i in src) { | ||
debug(i, src[i]); | ||
if (!re[i]) | ||
re[i] = new RegExp(src[i]); | ||
} | ||
exports.valid = exports.parse = parse; | ||
function parse(version) { | ||
if (!version.match(re.loose)) | ||
return null; | ||
return new SemVer(version); | ||
} | ||
exports.clean = clean; | ||
function clean(version) { | ||
return new SemVer(version).version; | ||
} | ||
exports.SemVer = SemVer; | ||
function SemVer(version) { | ||
if (version instanceof SemVer) | ||
return version; | ||
if (!(this instanceof SemVer)) | ||
return new SemVer(version); | ||
debug('SemVer', version); | ||
var m = version.match(re.loose); | ||
if (!m) | ||
throw new TypeError('Invalid Version: ' + version); | ||
this.raw = version; | ||
this.major = m[1]; | ||
this.minor = m[2]; | ||
this.patch = m[3]; | ||
this.prerelease = m[4] ? m[4].split('.') : []; | ||
this.build = m[5] ? m[5].split('.') : []; | ||
this.format(); | ||
} | ||
SemVer.prototype.format = function() { | ||
this.version = this.major + '.' + this.minor + '.' + this.patch; | ||
if (this.prerelease.length) | ||
this.version += '-' + this.prerelease.join('.'); | ||
return this.version; | ||
} | ||
SemVer.prototype.inspect = function() { | ||
return '<SemVer "' + this + '">'; | ||
}; | ||
SemVer.prototype.toString = function() { | ||
return this.value; | ||
}; | ||
SemVer.prototype.compare = function(other) { | ||
if (!(other instanceof SemVer)) | ||
other = new SemVer(other); | ||
return this.compareMain(other) || this.comparePre(other); | ||
}; | ||
SemVer.prototype.compareMain = function(other) { | ||
if (!(other instanceof SemVer)) | ||
other = new SemVer(other); | ||
return compareIdentifiers(this.major, other.major) || | ||
compareIdentifiers(this.minor, other.minor) || | ||
compareIdentifiers(this.patch, other.patch); | ||
}; | ||
SemVer.prototype.comparePre = function(other) { | ||
if (!(other instanceof SemVer)) | ||
other = new SemVer(other); | ||
// NOT having a prerelease is > having one | ||
if (this.prerelease.length && !other.prerelease.length) | ||
return -1; | ||
else if (!this.prerelease.length && other.prerelease.length) | ||
return 1; | ||
else if (!this.prerelease.lenth && !other.prerelease.length) | ||
return 0; | ||
var i = 0; | ||
do { | ||
var a = this.prerelease[i]; | ||
var b = other.prerelease[i]; | ||
debug('prerelease compare', i, a, b); | ||
if (a === undefined && b === undefined) | ||
return 0; | ||
else if (b === undefined) | ||
return 1; | ||
else if (a === undefined) | ||
return -1; | ||
else if (a === b) | ||
continue; | ||
else | ||
return compareIdentifiers(a, b); | ||
} while (++i); | ||
}; | ||
SemVer.prototype.inc = function(release) { | ||
switch (release) { | ||
case 'major': | ||
this.major++; | ||
this.minor = -1; | ||
case 'minor': | ||
this.minor++; | ||
this.patch = -1; | ||
case 'patch': | ||
this.patch++; | ||
this.prerelease = []; | ||
break; | ||
default: | ||
throw new Error('invalid increment argument: '+release); | ||
} | ||
}) | ||
this.format(); | ||
return this; | ||
}; | ||
exports.rangeReplace = ">=$1 <=$7" | ||
exports.clean = clean | ||
exports.compare = compare | ||
exports.rcompare = rcompare | ||
exports.satisfies = satisfies | ||
exports.gt = gt | ||
exports.gte = gte | ||
exports.lt = lt | ||
exports.lte = lte | ||
exports.eq = eq | ||
exports.neq = neq | ||
exports.cmp = cmp | ||
exports.inc = inc | ||
exports.inc = inc; | ||
function inc(version, release) { | ||
try { | ||
return new SemVer(version).inc(release).version; | ||
} catch (er) { | ||
return null; | ||
} | ||
} | ||
exports.valid = valid | ||
exports.validPackage = validPackage | ||
exports.validRange = validRange | ||
exports.maxSatisfying = maxSatisfying | ||
exports.compareIdentifiers = compareIdentifiers; | ||
exports.replaceStars = replaceStars | ||
exports.toComparators = toComparators | ||
var numeric = /^[0-9]+$/; | ||
function compareIdentifiers(a, b) { | ||
var anum = numeric.test(a); | ||
var bnum = numeric.test(b); | ||
function stringify (version) { | ||
var v = version | ||
return [v[1]||'', v[2]||'', v[3]||''].join(".") + (v[4]||'') + (v[5]||'') | ||
if (anum && bnum) { | ||
a = +a; | ||
b = +b; | ||
} | ||
return (anum && !bnum) ? -1 | ||
: (bnum && !anum) ? 1 | ||
: a < b ? -1 | ||
: a > b ? 1 | ||
: 0; | ||
} | ||
function clean (version) { | ||
version = exports.parse(version) | ||
if (!version) return version | ||
return stringify(version) | ||
exports.rcompareIdentifiers = rcompareIdentifiers; | ||
function rcompareIdentifiers(a, b) { | ||
return compareIdentifiers(b, a); | ||
} | ||
function valid (version) { | ||
if (typeof version !== "string") return null | ||
return exports.parse(version) && version.trim().replace(/^[v=]+/, '') | ||
exports.compare = compare; | ||
function compare(a, b) { | ||
return new SemVer(a).compare(b); | ||
} | ||
function validPackage (version) { | ||
if (typeof version !== "string") return null | ||
return version.match(expressions.parsePackage) && version.trim() | ||
exports.rcompare = rcompare; | ||
function rcompare(a, b) { | ||
return compare(b, a); | ||
} | ||
// range can be one of: | ||
// "1.0.3 - 2.0.0" range, inclusive, like ">=1.0.3 <=2.0.0" | ||
// ">1.0.2" like 1.0.3 - 9999.9999.9999 | ||
// ">=1.0.2" like 1.0.2 - 9999.9999.9999 | ||
// "<2.0.0" like 0.0.0 - 1.9999.9999 | ||
// ">1.0.2 <2.0.0" like 1.0.3 - 1.9999.9999 | ||
var starExpression = /(<|>)?=?\s*\*/g | ||
, starReplace = "" | ||
, compTrimExpression = new RegExp("((<|>)?=|<|>)\\s*(" | ||
+semver+"|"+xRangePlain+")", "g") | ||
, compTrimReplace = "$1$3" | ||
exports.sort = sort; | ||
function sort(list) { | ||
return list.sort(exports.compare); | ||
} | ||
function toComparators (range) { | ||
var ret = (range || "").trim() | ||
.replace(expressions.parseRange, exports.rangeReplace) | ||
.replace(compTrimExpression, compTrimReplace) | ||
.split(/\s+/) | ||
.join(" ") | ||
.split("||") | ||
.map(function (orchunk) { | ||
return orchunk | ||
.replace(new RegExp("(" + exprLoneSpermy + ")\\s+"), "$1") | ||
.split(" ") | ||
.map(replaceXRanges) | ||
.map(replaceSpermies) | ||
.map(replaceStars) | ||
.join(" ").trim() | ||
}) | ||
.map(function (orchunk) { | ||
return orchunk | ||
.trim() | ||
.split(/\s+/) | ||
.filter(function (c) { return c.match(expressions.validComparator) }) | ||
}) | ||
.filter(function (c) { return c.length }) | ||
return ret | ||
exports.rsort = rsort; | ||
function rsort(list) { | ||
return list.sort(exports.rcompare); | ||
} | ||
function replaceStars (stars) { | ||
return stars.trim().replace(starExpression, starReplace) | ||
exports.gt = gt; | ||
function gt(a, b) { | ||
return compare(a, b) > 0; | ||
} | ||
// "2.x","2.x.x" --> ">=2.0.0- <2.1.0-" | ||
// "2.3.x" --> ">=2.3.0- <2.4.0-" | ||
function replaceXRanges (ranges) { | ||
return ranges.split(/\s+/) | ||
.map(replaceXRange) | ||
.join(" ") | ||
exports.lt = lt; | ||
function lt(a, b) { | ||
return compare(a, b) < 0; | ||
} | ||
function replaceXRange (version) { | ||
return version.trim().replace(expressions.parseXRange, | ||
function (v, gtlt, M, m, p, t) { | ||
var anyX = !M || M.toLowerCase() === "x" || M === "*" | ||
|| !m || m.toLowerCase() === "x" || m === "*" | ||
|| !p || p.toLowerCase() === "x" || p === "*" | ||
, ret = v | ||
exports.eq = eq; | ||
function eq(a, b) { | ||
return compare(a, b) === 0; | ||
} | ||
if (gtlt && anyX) { | ||
// just replace x'es with zeroes | ||
;(!M || M === "*" || M.toLowerCase() === "x") && (M = 0) | ||
;(!m || m === "*" || m.toLowerCase() === "x") && (m = 0) | ||
;(!p || p === "*" || p.toLowerCase() === "x") && (p = 0) | ||
ret = gtlt + M+"."+m+"."+p+"-" | ||
} else if (!M || M === "*" || M.toLowerCase() === "x") { | ||
ret = "*" // allow any | ||
} else if (!m || m === "*" || m.toLowerCase() === "x") { | ||
// append "-" onto the version, otherwise | ||
// "1.x.x" matches "2.0.0beta", since the tag | ||
// *lowers* the version value | ||
ret = ">="+M+".0.0- <"+(+M+1)+".0.0-" | ||
} else if (!p || p === "*" || p.toLowerCase() === "x") { | ||
ret = ">="+M+"."+m+".0- <"+M+"."+(+m+1)+".0-" | ||
exports.neq = neq; | ||
function neq(a, b) { | ||
return compare(a, b) !== 0; | ||
} | ||
exports.gte = gte; | ||
function gte(a, b) { | ||
return compare(a, b) >= 0; | ||
} | ||
exports.lte = lte; | ||
function lte(a, b) { | ||
return compare(a, b) <= 0; | ||
} | ||
exports.cmp = cmp; | ||
function cmp(a, op, b) { | ||
var ret; | ||
switch(op) { | ||
case '===': ret = a === b; break; | ||
case '!==': ret = a !== b; break; | ||
case '': case '=': case '==': ret = eq(a, b); break; | ||
case '!=': ret = neq(a, b); break; | ||
case '>': ret = gt(a, b); break; | ||
case '>=': ret = gte(a, b); break; | ||
case '<': ret = lt(a, b); break; | ||
case '<=': ret = lte(a, b); break; | ||
default: throw new TypeError('Invalid operator: ' + op); | ||
} | ||
return ret; | ||
} | ||
exports.Comparator = Comparator; | ||
function Comparator(compString) { | ||
debug('comparator', compString); | ||
this.parse(compString); | ||
if (this.semver === ANY) | ||
this.value = ''; | ||
else | ||
this.value = this.operator + this.semver.version; | ||
} | ||
var ANY = {}; | ||
Comparator.prototype.parse = function(compString) { | ||
var m = compString.match(re.comparator); | ||
if (!m) | ||
throw new TypeError('Invalid comparator: ' + compString); | ||
// debug('parsed comparator', m); | ||
this.operator = m[1]; | ||
if (!m[2]) | ||
this.semver = ANY; | ||
else { | ||
this.semver = new SemVer(m[2]); | ||
// <1.2.3-rc DOES allow 1.2.3-beta (has prerelease) | ||
// >=1.2.3 DOES NOT allow 1.2.3-beta | ||
// <=1.2.3 DOES allow 1.2.3-beta | ||
// However, <1.2.3 does NOT allow 1.2.3-beta, | ||
// even though `1.2.3-beta < 1.2.3` | ||
// The assumption is that the 1.2.3 version has something you | ||
// *don't* want, so we push the prerelease down to the minimum. | ||
if (this.operator === '<' && !this.semver.prerelease.length) { | ||
this.semver.prerelease = ['0']; | ||
this.semver.format(); | ||
} | ||
return ret | ||
}) | ||
} | ||
}; | ||
Comparator.prototype.inspect = function() { | ||
return '<SemVer Comparator "' + this + '">'; | ||
}; | ||
Comparator.prototype.toString = function() { | ||
return this.value; | ||
}; | ||
Comparator.prototype.test = function(version) { | ||
return (this.semver === ANY) ? true : | ||
cmp(version, this.operator, this.semver); | ||
}; | ||
exports.Range = Range; | ||
function Range (range) { | ||
if (range instanceof Range) | ||
return range; | ||
if (!(this instanceof Range)) | ||
return new Range(range); | ||
// First, split based on boolean or || | ||
this.raw = range; | ||
this.set = range.split(/\s*\|\|\s*/).map(function(range) { | ||
return this.parseRange(range.trim()); | ||
}, this).filter(function(c) { | ||
// throw out any that are not relevant for whatever reason | ||
return c.length; | ||
}); | ||
if (!this.set.length) { | ||
throw new TypeError('Invalid SemVer Range: ' + range); | ||
} | ||
this.format(); | ||
} | ||
Range.prototype.inspect = function() { | ||
return '<SemVer Range "' + this.range + '">'; | ||
}; | ||
Range.prototype.format = function() { | ||
this.range = this.set.map(function(comps) { | ||
return comps.join(' ').trim(); | ||
}).join('||').trim(); | ||
return this.range; | ||
}; | ||
Range.prototype.toString = function() { | ||
return this.range; | ||
}; | ||
Range.prototype.parseRange = function(range) { | ||
range = range.trim(); | ||
debug('range', range); | ||
// `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4` | ||
range = range.replace(re.hyphenRange, hyphenReplace); | ||
debug('hyphen replace', range); | ||
// `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5` | ||
range = range.replace(re.comparatorTrim, comparatorTrimReplace); | ||
debug('comparator trim', range); | ||
// `~ 1.2.3` => `~1.2.3` | ||
range = range.replace(re.tildeTrim, tildeTrimReplace); | ||
// normalize spaces | ||
range = range.split(/\s+/).join(' '); | ||
var set = range.split(' ').map(function(comp) { | ||
return parseComparator(comp); | ||
}).join(' ').split(/\s+/).filter(function(comp) { | ||
// Throw out any that are not valid comparators | ||
return !!comp.match(re.comparator); | ||
}).map(function(comp) { | ||
return new Comparator(comp); | ||
}); | ||
return set; | ||
}; | ||
// Mostly just for testing and legacy API reasons | ||
exports.toComparators = toComparators; | ||
function toComparators(range) { | ||
return new Range(range).set.map(function(comp) { | ||
return comp.map(function(c) { | ||
return c.value; | ||
}).join(' ').trim().split(' '); | ||
}); | ||
} | ||
function parseComparator(comp) { | ||
// comprised of xranges, tildes, stars, and gtlt's at this point. | ||
// already replaced the hyphen ranges | ||
// turn into a set of JUST comparators. | ||
debug('comp', comp); | ||
comp = replaceTildes(comp); | ||
debug('tildes', comp); | ||
comp = replaceXRanges(comp); | ||
debug('xrange', comp); | ||
comp = replaceStars(comp); | ||
debug('stars', comp); | ||
return comp; | ||
}; | ||
function isX(id) { | ||
return !id || id.toLowerCase() === 'x' || id === '*'; | ||
} | ||
// ~, ~> --> * (any, kinda silly) | ||
@@ -164,144 +529,121 @@ // ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0 | ||
// ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0 | ||
function replaceSpermies (version) { | ||
return version.trim().replace(expressions.parseSpermy, | ||
function (v, gtlt, M, m, p, t) { | ||
if (gtlt) throw new Error( | ||
"Using '"+gtlt+"' with ~ makes no sense. Don't do it.") | ||
function replaceTildes(comp) { | ||
return comp.trim().split(/\s+/).map(replaceTilde).join(' '); | ||
} | ||
if (!M || M.toLowerCase() === "x") { | ||
return "" | ||
} | ||
// ~1 == >=1.0.0- <2.0.0- | ||
if (!m || m.toLowerCase() === "x") { | ||
return ">="+M+".0.0- <"+(+M+1)+".0.0-" | ||
} | ||
// ~1.2 == >=1.2.0- <1.3.0- | ||
if (!p || p.toLowerCase() === "x") { | ||
return ">="+M+"."+m+".0- <"+M+"."+(+m+1)+".0-" | ||
} | ||
// ~1.2.3 == >=1.2.3- <1.3.0- | ||
t = t || "-" | ||
return ">="+M+"."+m+"."+p+t+" <"+M+"."+(+m+1)+".0-" | ||
}) | ||
function replaceTilde(comp) { | ||
return comp.replace(re.tilde, function (_, M, m, p, pr) { | ||
debug('tilde', comp, _, M, m, p, pr); | ||
if (isX(M)) | ||
ret = ''; | ||
else if (isX(m)) | ||
ret = '>=' + M + '.0.0-0 <' + (+M + 1) + '.0.0-0'; | ||
else if (isX(p)) | ||
// ~1.2 == >=1.2.0- <1.3.0- | ||
ret = '>=' + M + '.' + m + '.0-0 <' + M + '.' + (+m + 1) + '.0-0' | ||
else if (pr) { | ||
debug('replaceTilde pr', pr); | ||
if (pr.charAt(0) !== '-') | ||
pr = '-' + pr; | ||
ret = '>=' + M + '.' + m + '.' + p + pr + | ||
' <' + M + '.' + (+m + 1) + '.0-0'; | ||
} else | ||
// ~1.2.3 == >=1.2.3-0 <1.3.0-0 | ||
ret = '>=' + M + '.' + m + '.' + p + '-0' + | ||
' <' + M + '.' + (+m + 1) + '.0-0' | ||
debug('tilde return', ret); | ||
return ret; | ||
}); | ||
} | ||
function validRange (range) { | ||
range = replaceStars(range) | ||
var c = toComparators(range) | ||
return (c.length === 0) | ||
? null | ||
: c.map(function (c) { return c.join(" ") }).join("||") | ||
function replaceXRanges(comp) { | ||
return comp.split(/\s+/).map(replaceXRange).join(' '); | ||
} | ||
// returns the highest satisfying version in the list, or undefined | ||
function maxSatisfying (versions, range) { | ||
return versions | ||
.filter(function (v) { return satisfies(v, range) }) | ||
.sort(compare) | ||
.pop() | ||
} | ||
function satisfies (version, range) { | ||
version = valid(version) | ||
if (!version) return false | ||
range = toComparators(range) | ||
for (var i = 0, l = range.length ; i < l ; i ++) { | ||
var ok = false | ||
for (var j = 0, ll = range[i].length ; j < ll ; j ++) { | ||
var r = range[i][j] | ||
, gtlt = r.charAt(0) === ">" ? gt | ||
: r.charAt(0) === "<" ? lt | ||
: false | ||
, eq = r.charAt(!!gtlt) === "=" | ||
, sub = (!!eq) + (!!gtlt) | ||
if (!gtlt) eq = true | ||
r = r.substr(sub) | ||
r = (r === "") ? r : valid(r) | ||
ok = (r === "") || (eq && r === version) || (gtlt && gtlt(version, r)) | ||
if (!ok) break | ||
function replaceXRange(comp) { | ||
comp = comp.trim(); | ||
return comp.replace(re.xRange, function (ret, gtlt, M, m, p, pr) { | ||
debug('xRange', comp, ret, gtlt, M, m, p, pr); | ||
var xM = isX(M); | ||
var xm = xM || isX(m); | ||
var xp = xm || isX(p); | ||
var anyX = xp; | ||
if (gtlt === '=' && anyX) | ||
gtlt = ''; | ||
if (gtlt && anyX) { | ||
// replace X with 0, and then append the -0 min-prerelease | ||
if (xM) | ||
M = 0; | ||
if (xm) | ||
m = 0; | ||
if (xp) | ||
p = 0; | ||
ret = gtlt + M + '.' + m + '.' + p + '-0'; | ||
} else if (xM) { | ||
// allow any | ||
ret = '*'; | ||
} else if (xm) { | ||
// append '-0' onto the version, otherwise | ||
// '1.x.x' matches '2.0.0-beta', since the tag | ||
// *lowers* the version value | ||
ret = '>=' + M + '.0.0-0 <' + (+M + 1) + '.0.0-0'; | ||
} else if (xp) { | ||
ret = '>=' + M + '.' + m + '.0-0 <' + M + '.' + (+m + 1) + '.0-0'; | ||
} | ||
if (ok) return true | ||
} | ||
return false | ||
} | ||
// return v1 > v2 ? 1 : -1 | ||
function compare (v1, v2) { | ||
var g = gt(v1, v2) | ||
return g === null ? 0 : g ? 1 : -1 | ||
debug('xRange return', ret); | ||
return ret; | ||
}); | ||
} | ||
function rcompare (v1, v2) { | ||
return compare(v2, v1) | ||
// Because * is AND-ed with everything else in the comparator, | ||
// and '' means "any version", just remove the *s entirely. | ||
function replaceStars(comp) { | ||
return comp.trim().replace(re.star, '') | ||
} | ||
function lt (v1, v2) { return gt(v2, v1) } | ||
function gte (v1, v2) { return !lt(v1, v2) } | ||
function lte (v1, v2) { return !gt(v1, v2) } | ||
function eq (v1, v2) { return gt(v1, v2) === null } | ||
function neq (v1, v2) { return gt(v1, v2) !== null } | ||
function cmp (v1, c, v2) { | ||
switch (c) { | ||
case ">": return gt(v1, v2) | ||
case "<": return lt(v1, v2) | ||
case ">=": return gte(v1, v2) | ||
case "<=": return lte(v1, v2) | ||
case "==": return eq(v1, v2) | ||
case "!=": return neq(v1, v2) | ||
case "===": return v1 === v2 | ||
case "!==": return v1 !== v2 | ||
default: throw new Error("Y U NO USE VALID COMPARATOR!? "+c) | ||
// if ANY of the sets match ALL of its comparators, then pass | ||
Range.prototype.test = function(version) { | ||
for (var i = 0; i < this.set.length; i++) { | ||
if (testSet(this.set[i], version)) | ||
return true; | ||
} | ||
return false; | ||
}; | ||
function testSet(set, version) { | ||
for (var i = 0; i < set.length; i++) { | ||
if (!set[i].test(version)) | ||
return false; | ||
} | ||
return true; | ||
} | ||
// return v1 > v2 | ||
function num (v) { | ||
return v === undefined ? -1 : parseInt((v||"0").replace(/[^0-9]+/g, ''), 10) | ||
exports.satisfies = satisfies; | ||
function satisfies (version, range) { | ||
return new Range(range).test(version); | ||
} | ||
function gt (v1, v2) { | ||
v1 = exports.parse(v1) | ||
v2 = exports.parse(v2) | ||
if (!v1 || !v2) return false | ||
for (var i = 1; i < 5; i ++) { | ||
v1[i] = num(v1[i]) | ||
v2[i] = num(v2[i]) | ||
if (v1[i] > v2[i]) return true | ||
else if (v1[i] !== v2[i]) return false | ||
} | ||
// no tag is > than any tag, or use lexicographical order. | ||
var tag1 = v1[5] || "" | ||
, tag2 = v2[5] || "" | ||
// kludge: null means they were equal. falsey, and detectable. | ||
// embarrassingly overclever, though, I know. | ||
return tag1 === tag2 ? null | ||
: !tag1 ? true | ||
: !tag2 ? false | ||
: tag1 > tag2 | ||
exports.maxSatisfying = maxSatisfying; | ||
function maxSatisfying (versions, range) { | ||
return versions.filter(function(version) { | ||
return satisfies(version, range); | ||
}).sort(compare)[0] || null; | ||
} | ||
function inc (version, release) { | ||
version = exports.parse(version) | ||
if (!version) return null | ||
var parsedIndexLookup = | ||
{ 'major': 1 | ||
, 'minor': 2 | ||
, 'patch': 3 | ||
, 'build': 4 } | ||
var incIndex = parsedIndexLookup[release] | ||
if (incIndex === undefined) return null | ||
var current = num(version[incIndex]) | ||
version[incIndex] = current === -1 ? 1 : current + 1 | ||
for (var i = incIndex + 1; i < 5; i ++) { | ||
if (num(version[i]) !== -1) version[i] = "0" | ||
exports.validRange = validRange; | ||
function validRange(range) { | ||
try { | ||
return new Range(range).range; | ||
} catch (er) { | ||
return null; | ||
} | ||
} | ||
if (version[4]) version[4] = "-" + version[4] | ||
version[5] = "" | ||
return stringify(version) | ||
} | ||
})(typeof exports === "object" ? exports : semver = {}) | ||
})(typeof exports === 'object' ? exports : semver = {}); |
219
test.js
@@ -17,3 +17,3 @@ var tap = require("tap") | ||
tap.plan(8) | ||
tap.plan(7); | ||
@@ -23,3 +23,3 @@ test("\ncomparison tests", function (t) { | ||
// version1 should be greater than version2 | ||
; [ ["0.0.0", "0.0.0foo"] | ||
; [ ["0.0.0", "0.0.0-foo"] | ||
, ["0.0.1", "0.0.0"] | ||
@@ -30,3 +30,3 @@ , ["1.0.0", "0.9.9"] | ||
, ["2.0.0", "1.2.3"] | ||
, ["v0.0.0", "0.0.0foo"] | ||
, ["v0.0.0", "0.0.0-foo"] | ||
, ["v0.0.1", "0.0.0"] | ||
@@ -37,3 +37,3 @@ , ["v1.0.0", "0.9.9"] | ||
, ["v2.0.0", "1.2.3"] | ||
, ["0.0.0", "v0.0.0foo"] | ||
, ["0.0.0", "v0.0.0-foo"] | ||
, ["0.0.1", "v0.0.0"] | ||
@@ -45,8 +45,12 @@ , ["1.0.0", "v0.9.9"] | ||
, ["1.2.3", "1.2.3-asdf"] | ||
, ["1.2.3-4", "1.2.3"] | ||
, ["1.2.3-4-foo", "1.2.3"] | ||
, ["1.2.3-5", "1.2.3-5-foo"] | ||
, ["1.2.3", "1.2.3-4"] | ||
, ["1.2.3", "1.2.3-4-foo"] | ||
, ["1.2.3-5-foo", "1.2.3-5"] | ||
, ["1.2.3-5", "1.2.3-4"] | ||
, ["1.2.3-5-foo", "1.2.3-5-Foo"] | ||
, ["3.0.0", "2.7.2+"] | ||
, ["3.0.0", "2.7.2+asdf"] | ||
, ["1.2.3-a.10", "1.2.3-a.5"] | ||
, ["1.2.3-a.b", "1.2.3-a.5"] | ||
, ["1.2.3-a.b", "1.2.3-a"] | ||
, ["1.2.3-a.b.c.10.d.5", "1.2.3-a.b.c.5.d.100"] | ||
].forEach(function (v) { | ||
@@ -89,18 +93,20 @@ var v0 = v[0] | ||
, ["1.2.3-0", " = 1.2.3-0"] | ||
, ["1.2.3-01", "v1.2.3-1"] | ||
, ["1.2.3-01", "=1.2.3-1"] | ||
, ["1.2.3-01", "v 1.2.3-1"] | ||
, ["1.2.3-01", "= 1.2.3-1"] | ||
, ["1.2.3-01", " v1.2.3-1"] | ||
, ["1.2.3-01", " =1.2.3-1"] | ||
, ["1.2.3-01", " v 1.2.3-1"] | ||
, ["1.2.3-01", " = 1.2.3-1"] | ||
, ["1.2.3beta", "v1.2.3beta"] | ||
, ["1.2.3beta", "=1.2.3beta"] | ||
, ["1.2.3beta", "v 1.2.3beta"] | ||
, ["1.2.3beta", "= 1.2.3beta"] | ||
, ["1.2.3beta", " v1.2.3beta"] | ||
, ["1.2.3beta", " =1.2.3beta"] | ||
, ["1.2.3beta", " v 1.2.3beta"] | ||
, ["1.2.3beta", " = 1.2.3beta"] | ||
, ["1.2.3-1", "v1.2.3-1"] | ||
, ["1.2.3-1", "=1.2.3-1"] | ||
, ["1.2.3-1", "v 1.2.3-1"] | ||
, ["1.2.3-1", "= 1.2.3-1"] | ||
, ["1.2.3-1", " v1.2.3-1"] | ||
, ["1.2.3-1", " =1.2.3-1"] | ||
, ["1.2.3-1", " v 1.2.3-1"] | ||
, ["1.2.3-1", " = 1.2.3-1"] | ||
, ["1.2.3-beta", "v1.2.3-beta"] | ||
, ["1.2.3-beta", "=1.2.3-beta"] | ||
, ["1.2.3-beta", "v 1.2.3-beta"] | ||
, ["1.2.3-beta", "= 1.2.3-beta"] | ||
, ["1.2.3-beta", " v1.2.3-beta"] | ||
, ["1.2.3-beta", " =1.2.3-beta"] | ||
, ["1.2.3-beta", " v 1.2.3-beta"] | ||
, ["1.2.3-beta", " = 1.2.3-beta"] | ||
, ["1.2.3-beta+build", " = 1.2.3-beta+otherbuild"] | ||
, ["1.2.3+build", " = 1.2.3+otherbuild"] | ||
].forEach(function (v) { | ||
@@ -203,2 +209,3 @@ var v0 = v[0] | ||
, ['>=1.2.1 >=1.2.3', '1.2.3'] | ||
, ['<=1.2.3', '1.2.3-beta'] | ||
].forEach(function (v) { | ||
@@ -258,2 +265,4 @@ t.ok(satisfies(v[1], v[0]), v[0]+" satisfied by "+v[1]) | ||
, ["<=0.7.x", "0.7.2"] | ||
, ["<1.2.3", "1.2.3-beta"] | ||
, ['=1.2.3', '1.2.3-beta'] | ||
].forEach(function (v) { | ||
@@ -271,10 +280,4 @@ t.ok(!satisfies(v[1], v[0]), v[0]+" not satisfied by "+v[1]) | ||
, [ "1.2.3", "patch", "1.2.4" ] | ||
, [ "1.2.3", "build", "1.2.3-1" ] | ||
, [ "1.2.3-4", "build", "1.2.3-5" ] | ||
, [ "1.2.3tag", "major", "2.0.0" ] | ||
, [ "1.2.3-tag", "major", "2.0.0" ] | ||
, [ "1.2.3tag", "build", "1.2.3-1" ] | ||
, [ "1.2.3-tag", "build", "1.2.3-1" ] | ||
, [ "1.2.3-4-tag", "build", "1.2.3-5" ] | ||
, [ "1.2.3-4tag", "build", "1.2.3-5" ] | ||
, [ "1.2.3", "fake", null ] | ||
@@ -289,17 +292,2 @@ , [ "fake", "major", null ] | ||
test("\nreplace stars test", function (t) { | ||
// replace stars with "" | ||
; [ [ "", "" ] | ||
, [ "*", "" ] | ||
, [ "> *", "" ] | ||
, [ "<*", "" ] | ||
, [ " >= *", "" ] | ||
, [ "* || 1.2.3", " || 1.2.3" ] | ||
].forEach(function (v) { | ||
t.equal(replaceStars(v[0]), v[1], "replaceStars("+v[0]+") === "+v[1]) | ||
}) | ||
t.end() | ||
}) | ||
test("\nvalid range test", function (t) { | ||
@@ -311,3 +299,3 @@ // [range, result] | ||
, ["1.0.0", "1.0.0"] | ||
, [">=*", ""] | ||
, [">=*", ">=0.0.0-0"] | ||
, ["", ""] | ||
@@ -319,7 +307,7 @@ , ["*", ""] | ||
, ["<=2.0.0", "<=2.0.0"] | ||
, ["1", ">=1.0.0- <2.0.0-"] | ||
, ["1", ">=1.0.0-0 <2.0.0-0"] | ||
, ["<=2.0.0", "<=2.0.0"] | ||
, ["<=2.0.0", "<=2.0.0"] | ||
, ["<2.0.0", "<2.0.0"] | ||
, ["<2.0.0", "<2.0.0"] | ||
, ["<2.0.0", "<2.0.0-0"] | ||
, ["<2.0.0", "<2.0.0-0"] | ||
, [">= 1.0.0", ">=1.0.0"] | ||
@@ -333,38 +321,37 @@ , [">= 1.0.0", ">=1.0.0"] | ||
, ["<= 2.0.0", "<=2.0.0"] | ||
, ["< 2.0.0", "<2.0.0"] | ||
, ["< 2.0.0", "<2.0.0"] | ||
, ["< 2.0.0", "<2.0.0-0"] | ||
, ["< 2.0.0", "<2.0.0-0"] | ||
, [">=0.1.97", ">=0.1.97"] | ||
, [">=0.1.97", ">=0.1.97"] | ||
, ["0.1.20 || 1.2.4", "0.1.20||1.2.4"] | ||
, [">=0.2.3 || <0.0.1", ">=0.2.3||<0.0.1"] | ||
, [">=0.2.3 || <0.0.1", ">=0.2.3||<0.0.1"] | ||
, [">=0.2.3 || <0.0.1", ">=0.2.3||<0.0.1"] | ||
, [">=0.2.3 || <0.0.1", ">=0.2.3||<0.0.1-0"] | ||
, [">=0.2.3 || <0.0.1", ">=0.2.3||<0.0.1-0"] | ||
, [">=0.2.3 || <0.0.1", ">=0.2.3||<0.0.1-0"] | ||
, ["||", "||"] | ||
, ["2.x.x", ">=2.0.0- <3.0.0-"] | ||
, ["1.2.x", ">=1.2.0- <1.3.0-"] | ||
, ["1.2.x || 2.x", ">=1.2.0- <1.3.0-||>=2.0.0- <3.0.0-"] | ||
, ["1.2.x || 2.x", ">=1.2.0- <1.3.0-||>=2.0.0- <3.0.0-"] | ||
, ["2.x.x", ">=2.0.0-0 <3.0.0-0"] | ||
, ["1.2.x", ">=1.2.0-0 <1.3.0-0"] | ||
, ["1.2.x || 2.x", ">=1.2.0-0 <1.3.0-0||>=2.0.0-0 <3.0.0-0"] | ||
, ["1.2.x || 2.x", ">=1.2.0-0 <1.3.0-0||>=2.0.0-0 <3.0.0-0"] | ||
, ["x", ""] | ||
, ["2.*.*", null] | ||
, ["1.2.*", null] | ||
, ["1.2.* || 2.*", null] | ||
, ["1.2.* || 2.*", null] | ||
, ["2.*.*", '>=2.0.0-0 <3.0.0-0'] | ||
, ["1.2.*", '>=1.2.0-0 <1.3.0-0'] | ||
, ["1.2.* || 2.*", '>=1.2.0-0 <1.3.0-0||>=2.0.0-0 <3.0.0-0'] | ||
, ["*", ""] | ||
, ["2", ">=2.0.0- <3.0.0-"] | ||
, ["2.3", ">=2.3.0- <2.4.0-"] | ||
, ["~2.4", ">=2.4.0- <2.5.0-"] | ||
, ["~2.4", ">=2.4.0- <2.5.0-"] | ||
, ["~>3.2.1", ">=3.2.1- <3.3.0-"] | ||
, ["~1", ">=1.0.0- <2.0.0-"] | ||
, ["~>1", ">=1.0.0- <2.0.0-"] | ||
, ["~> 1", ">=1.0.0- <2.0.0-"] | ||
, ["~1.0", ">=1.0.0- <1.1.0-"] | ||
, ["~ 1.0", ">=1.0.0- <1.1.0-"] | ||
, ["<1", "<1.0.0-"] | ||
, ["< 1", "<1.0.0-"] | ||
, [">=1", ">=1.0.0-"] | ||
, [">= 1", ">=1.0.0-"] | ||
, ["<1.2", "<1.2.0-"] | ||
, ["< 1.2", "<1.2.0-"] | ||
, ["1", ">=1.0.0- <2.0.0-"] | ||
, ["2", ">=2.0.0-0 <3.0.0-0"] | ||
, ["2.3", ">=2.3.0-0 <2.4.0-0"] | ||
, ["~2.4", ">=2.4.0-0 <2.5.0-0"] | ||
, ["~2.4", ">=2.4.0-0 <2.5.0-0"] | ||
, ["~>3.2.1", ">=3.2.1-0 <3.3.0-0"] | ||
, ["~1", ">=1.0.0-0 <2.0.0-0"] | ||
, ["~>1", ">=1.0.0-0 <2.0.0-0"] | ||
, ["~> 1", ">=1.0.0-0 <2.0.0-0"] | ||
, ["~1.0", ">=1.0.0-0 <1.1.0-0"] | ||
, ["~ 1.0", ">=1.0.0-0 <1.1.0-0"] | ||
, ["<1", "<1.0.0-0"] | ||
, ["< 1", "<1.0.0-0"] | ||
, [">=1", ">=1.0.0-0"] | ||
, [">= 1", ">=1.0.0-0"] | ||
, ["<1.2", "<1.2.0-0"] | ||
, ["< 1.2", "<1.2.0-0"] | ||
, ["1", ">=1.0.0-0 <2.0.0-0"] | ||
].forEach(function (v) { | ||
@@ -382,3 +369,3 @@ t.equal(validRange(v[0]), v[1], "validRange("+v[0]+") === "+v[1]) | ||
, ["1.0.0", [["1.0.0"]] ] | ||
, [">=*", [[">=0.0.0-"]] ] | ||
, [">=*", [[">=0.0.0-0"]] ] | ||
, ["", [[""]]] | ||
@@ -393,7 +380,7 @@ , ["*", [[""]] ] | ||
, ["<=2.0.0", [["<=2.0.0"]] ] | ||
, ["1", [[">=1.0.0-", "<2.0.0-"]] ] | ||
, ["1", [[">=1.0.0-0", "<2.0.0-0"]] ] | ||
, ["<=2.0.0", [["<=2.0.0"]] ] | ||
, ["<=2.0.0", [["<=2.0.0"]] ] | ||
, ["<2.0.0", [["<2.0.0"]] ] | ||
, ["<2.0.0", [["<2.0.0"]] ] | ||
, ["<2.0.0", [["<2.0.0-0"]] ] | ||
, ["<2.0.0", [["<2.0.0-0"]] ] | ||
, [">= 1.0.0", [[">=1.0.0"]] ] | ||
@@ -407,41 +394,41 @@ , [">= 1.0.0", [[">=1.0.0"]] ] | ||
, ["<= 2.0.0", [["<=2.0.0"]] ] | ||
, ["< 2.0.0", [["<2.0.0"]] ] | ||
, ["<\t2.0.0", [["<2.0.0"]] ] | ||
, ["< 2.0.0", [["<2.0.0-0"]] ] | ||
, ["<\t2.0.0", [["<2.0.0-0"]] ] | ||
, [">=0.1.97", [[">=0.1.97"]] ] | ||
, [">=0.1.97", [[">=0.1.97"]] ] | ||
, ["0.1.20 || 1.2.4", [["0.1.20"], ["1.2.4"]] ] | ||
, [">=0.2.3 || <0.0.1", [[">=0.2.3"], ["<0.0.1"]] ] | ||
, [">=0.2.3 || <0.0.1", [[">=0.2.3"], ["<0.0.1"]] ] | ||
, [">=0.2.3 || <0.0.1", [[">=0.2.3"], ["<0.0.1"]] ] | ||
, [">=0.2.3 || <0.0.1", [[">=0.2.3"], ["<0.0.1-0"]] ] | ||
, [">=0.2.3 || <0.0.1", [[">=0.2.3"], ["<0.0.1-0"]] ] | ||
, [">=0.2.3 || <0.0.1", [[">=0.2.3"], ["<0.0.1-0"]] ] | ||
, ["||", [[""], [""]] ] | ||
, ["2.x.x", [[">=2.0.0-", "<3.0.0-"]] ] | ||
, ["1.2.x", [[">=1.2.0-", "<1.3.0-"]] ] | ||
, ["1.2.x || 2.x", [[">=1.2.0-", "<1.3.0-"], [">=2.0.0-", "<3.0.0-"]] ] | ||
, ["1.2.x || 2.x", [[">=1.2.0-", "<1.3.0-"], [">=2.0.0-", "<3.0.0-"]] ] | ||
, ["2.x.x", [[">=2.0.0-0", "<3.0.0-0"]] ] | ||
, ["1.2.x", [[">=1.2.0-0", "<1.3.0-0"]] ] | ||
, ["1.2.x || 2.x", [[">=1.2.0-0", "<1.3.0-0"], [">=2.0.0-0", "<3.0.0-0"]] ] | ||
, ["1.2.x || 2.x", [[">=1.2.0-0", "<1.3.0-0"], [">=2.0.0-0", "<3.0.0-0"]] ] | ||
, ["x", [[""]] ] | ||
, ["2.*.*", [[">=2.0.0-", "<3.0.0-"]] ] | ||
, ["1.2.*", [[">=1.2.0-", "<1.3.0-"]] ] | ||
, ["1.2.* || 2.*", [[">=1.2.0-", "<1.3.0-"], [">=2.0.0-", "<3.0.0-"]] ] | ||
, ["1.2.* || 2.*", [[">=1.2.0-", "<1.3.0-"], [">=2.0.0-", "<3.0.0-"]] ] | ||
, ["2.*.*", [[">=2.0.0-0", "<3.0.0-0"]] ] | ||
, ["1.2.*", [[">=1.2.0-0", "<1.3.0-0"]] ] | ||
, ["1.2.* || 2.*", [[">=1.2.0-0", "<1.3.0-0"], [">=2.0.0-0", "<3.0.0-0"]] ] | ||
, ["1.2.* || 2.*", [[">=1.2.0-0", "<1.3.0-0"], [">=2.0.0-0", "<3.0.0-0"]] ] | ||
, ["*", [[""]] ] | ||
, ["2", [[">=2.0.0-", "<3.0.0-"]] ] | ||
, ["2.3", [[">=2.3.0-", "<2.4.0-"]] ] | ||
, ["~2.4", [[">=2.4.0-", "<2.5.0-"]] ] | ||
, ["~2.4", [[">=2.4.0-", "<2.5.0-"]] ] | ||
, ["~>3.2.1", [[">=3.2.1-", "<3.3.0-"]] ] | ||
, ["~1", [[">=1.0.0-", "<2.0.0-"]] ] | ||
, ["~>1", [[">=1.0.0-", "<2.0.0-"]] ] | ||
, ["~> 1", [[">=1.0.0-", "<2.0.0-"]] ] | ||
, ["~1.0", [[">=1.0.0-", "<1.1.0-"]] ] | ||
, ["~ 1.0", [[">=1.0.0-", "<1.1.0-"]] ] | ||
, ["~ 1.0.3", [[">=1.0.3-", "<1.1.0-"]] ] | ||
, ["~> 1.0.3", [[">=1.0.3-", "<1.1.0-"]] ] | ||
, ["<1", [["<1.0.0-"]] ] | ||
, ["< 1", [["<1.0.0-"]] ] | ||
, [">=1", [[">=1.0.0-"]] ] | ||
, [">= 1", [[">=1.0.0-"]] ] | ||
, ["<1.2", [["<1.2.0-"]] ] | ||
, ["< 1.2", [["<1.2.0-"]] ] | ||
, ["1", [[">=1.0.0-", "<2.0.0-"]] ] | ||
, ["1 2", [[">=1.0.0-", "<2.0.0-", ">=2.0.0-", "<3.0.0-"]] ] | ||
, ["2", [[">=2.0.0-0", "<3.0.0-0"]] ] | ||
, ["2.3", [[">=2.3.0-0", "<2.4.0-0"]] ] | ||
, ["~2.4", [[">=2.4.0-0", "<2.5.0-0"]] ] | ||
, ["~2.4", [[">=2.4.0-0", "<2.5.0-0"]] ] | ||
, ["~>3.2.1", [[">=3.2.1-0", "<3.3.0-0"]] ] | ||
, ["~1", [[">=1.0.0-0", "<2.0.0-0"]] ] | ||
, ["~>1", [[">=1.0.0-0", "<2.0.0-0"]] ] | ||
, ["~> 1", [[">=1.0.0-0", "<2.0.0-0"]] ] | ||
, ["~1.0", [[">=1.0.0-0", "<1.1.0-0"]] ] | ||
, ["~ 1.0", [[">=1.0.0-0", "<1.1.0-0"]] ] | ||
, ["~ 1.0.3", [[">=1.0.3-0", "<1.1.0-0"]] ] | ||
, ["~> 1.0.3", [[">=1.0.3-0", "<1.1.0-0"]] ] | ||
, ["<1", [["<1.0.0-0"]] ] | ||
, ["< 1", [["<1.0.0-0"]] ] | ||
, [">=1", [[">=1.0.0-0"]] ] | ||
, [">= 1", [[">=1.0.0-0"]] ] | ||
, ["<1.2", [["<1.2.0-0"]] ] | ||
, ["< 1.2", [["<1.2.0-0"]] ] | ||
, ["1", [[">=1.0.0-0", "<2.0.0-0"]] ] | ||
, ["1 2", [[">=1.0.0-0", "<2.0.0-0", ">=2.0.0-0", "<3.0.0-0"]] ] | ||
].forEach(function (v) { | ||
@@ -448,0 +435,0 @@ t.equivalent(toComparators(v[0]), v[1], "toComparators("+v[0]+") === "+JSON.stringify(v[1])) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Misc. License Issues
License(Experimental) A package's licensing information has fine-grained problems.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
36692
932
1
2
104
1