semver 5.2.0 → 5.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +4 -0
  2. package/package.json +1 -1
  3. package/semver.js +14 -5
package/README.md CHANGED
@@ -4,6 +4,8 @@ semver(1) -- The semantic versioner for npm
4
4
  ## Usage
5
5
 
6
6
  $ npm install semver
7
+ $ node
8
+ var semver = require('semver')
7
9
 
8
10
  semver.valid('1.2.3') // '1.2.3'
9
11
  semver.valid('a.b.c') // null
@@ -325,6 +327,8 @@ strings that they parse.
325
327
  range.
326
328
  * `maxSatisfying(versions, range)`: Return the highest version in the list
327
329
  that satisfies the range, or `null` if none of them do.
330
+ * `minSatisfying(versions, range)`: Return the lowest version in the list
331
+ that satisfies the range, or `null` if none of them do.
328
332
  * `gtr(version, range)`: Return `true` if version is greater than all the
329
333
  versions possible in the range.
330
334
  * `ltr(version, range)`: Return `true` if version is less than all the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "semver",
3
- "version": "5.2.0",
3
+ "version": "5.3.0",
4
4
  "description": "The semantic version parser used by npm.",
5
5
  "main": "semver.js",
6
6
  "scripts": {
package/semver.js CHANGED
@@ -314,9 +314,9 @@ function SemVer(version, loose) {
314
314
  else
315
315
  this.prerelease = m[4].split('.').map(function(id) {
316
316
  if (/^[0-9]+$/.test(id)) {
317
- var num = +id
317
+ var num = +id;
318
318
  if (num >= 0 && num < MAX_SAFE_INTEGER)
319
- return num
319
+ return num;
320
320
  }
321
321
  return id;
322
322
  });
@@ -966,11 +966,11 @@ function replaceXRange(comp, loose) {
966
966
  } else if (gtlt === '<=') {
967
967
  // <=0.7.x is actually <0.8.0, since any 0.7.x should
968
968
  // pass. Similarly, <=7.x is actually <8.0.0, etc.
969
- gtlt = '<'
969
+ gtlt = '<';
970
970
  if (xm)
971
- M = +M + 1
971
+ M = +M + 1;
972
972
  else
973
- m = +m + 1
973
+ m = +m + 1;
974
974
  }
975
975
 
976
976
  ret = gtlt + M + '.' + m + '.' + p;
@@ -1094,6 +1094,15 @@ function maxSatisfying(versions, range, loose) {
1094
1094
  })[0] || null;
1095
1095
  }
1096
1096
 
1097
+ exports.minSatisfying = minSatisfying;
1098
+ function minSatisfying(versions, range, loose) {
1099
+ return versions.filter(function(version) {
1100
+ return satisfies(version, range, loose);
1101
+ }).sort(function(a, b) {
1102
+ return compare(a, b, loose);
1103
+ })[0] || null;
1104
+ }
1105
+
1097
1106
  exports.validRange = validRange;
1098
1107
  function validRange(range, loose) {
1099
1108
  try {