diff options
Diffstat (limited to 'node_modules/semver/semver.js')
-rw-r--r-- | node_modules/semver/semver.js | 46 |
1 files changed, 22 insertions, 24 deletions
diff --git a/node_modules/semver/semver.js b/node_modules/semver/semver.js index cafcc006b..5f1a3c5c9 100644 --- a/node_modules/semver/semver.js +++ b/node_modules/semver/semver.js @@ -1,6 +1,4 @@ -// export the class if we are in a Node-like system. -if (typeof module === 'object' && module.exports === exports) - exports = module.exports = SemVer; +exports = module.exports = SemVer; // The debug function is excluded entirely from the minified version. /* nomin */ var debug; @@ -316,9 +314,9 @@ function SemVer(version, loose) { else this.prerelease = m[4].split('.').map(function(id) { if (/^[0-9]+$/.test(id)) { - var num = +id + var num = +id; if (num >= 0 && num < MAX_SAFE_INTEGER) - return num + return num; } return id; }); @@ -334,10 +332,6 @@ SemVer.prototype.format = function() { return this.version; }; -SemVer.prototype.inspect = function() { - return '<SemVer "' + this + '">'; -}; - SemVer.prototype.toString = function() { return this.version; }; @@ -483,6 +477,7 @@ SemVer.prototype.inc = function(release, identifier) { throw new Error('invalid increment argument: ' + release); } this.format(); + this.raw = this.version; return this; }; @@ -693,10 +688,6 @@ Comparator.prototype.parse = function(comp) { this.semver = new SemVer(m[2], this.loose); }; -Comparator.prototype.inspect = function() { - return '<SemVer Comparator "' + this + '">'; -}; - Comparator.prototype.toString = function() { return this.value; }; @@ -740,10 +731,6 @@ function Range(range, loose) { 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(); @@ -849,7 +836,7 @@ function replaceTilde(comp, loose) { else if (isX(m)) ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0'; else if (isX(p)) - // ~1.2 == >=1.2.0- <1.3.0- + // ~1.2 == >=1.2.0 <1.3.0 ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0'; else if (pr) { debug('replaceTilde pr', pr); @@ -979,11 +966,11 @@ function replaceXRange(comp, loose) { } else if (gtlt === '<=') { // <=0.7.x is actually <0.8.0, since any 0.7.x should // pass. Similarly, <=7.x is actually <8.0.0, etc. - gtlt = '<' + gtlt = '<'; if (xm) - M = +M + 1 + M = +M + 1; else - m = +m + 1 + m = +m + 1; } ret = gtlt + M + '.' + m + '.' + p; @@ -1107,6 +1094,15 @@ function maxSatisfying(versions, range, loose) { })[0] || null; } +exports.minSatisfying = minSatisfying; +function minSatisfying(versions, range, loose) { + return versions.filter(function(version) { + return satisfies(version, range, loose); + }).sort(function(a, b) { + return compare(a, b, loose); + })[0] || null; +} + exports.validRange = validRange; function validRange(range, loose) { try { @@ -1200,6 +1196,8 @@ function outside(version, range, hilo, loose) { return true; } -// Use the define() function if we're in AMD land -if (typeof define === 'function' && define.amd) - define(exports); +exports.prerelease = prerelease; +function prerelease(version, loose) { + var parsed = parse(version, loose); + return (parsed && parsed.prerelease.length) ? parsed.prerelease : null; +} |