Comparing version 1.0.0 to 1.0.1
{ "name" : "semver" | ||
, "version" : "1.0.0" | ||
, "version" : "1.0.1" | ||
, "description" : "The semantic version parser used by npm." | ||
, "main" : "semver.js" | ||
, "scripts" : { "test" : "node semver.js" } | ||
, "repository" : "git://github.com/isaacs/node-semver.git" | ||
, "bin" : { "semver" : "./bin/semver" } } |
@@ -11,2 +11,3 @@ # semver | ||
semver.valid('a.b.c') // false | ||
semver.clean(' =v1.2.3 ') // '1.2.3' | ||
semver.satisfies('1.2.3', '1.x || >=2.5.0 || 5.0.0 - 7.2.3') // true | ||
@@ -26,4 +27,5 @@ semver.gt('1.2.3', '9.8.7') // false | ||
Program exits successfully if all versions satisfy all | ||
ranges and are valid, and prints all satisfying versions. | ||
Program exits successfully if any valid version satisfies | ||
all supplied ranges, and prints all satisfying versions. | ||
If no versions are valid, or ranges are not satisfied, | ||
@@ -34,1 +36,54 @@ then exits failure. | ||
multiple versions to the utility will just sort them. | ||
## Versions | ||
A version is the following things, in this order: | ||
* 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 | ||
The following range styles are supported: | ||
* `>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 <2.0.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` | ||
Ranges can be joined with either a space (which implies "and") or a | ||
`||` (which implies "or"). |
@@ -62,3 +62,3 @@ | ||
function toComparators (range) { | ||
return range.trim() | ||
return (range || "").trim() | ||
.replace(expressions.parseRange, exports.rangeReplace) | ||
@@ -187,3 +187,5 @@ .split(/\s+/) | ||
// return v1 > v2 | ||
function num (v) { return parseInt((v||"0").replace(/[^0-9]+/g, ''), 10) } | ||
function num (v) { | ||
return v === undefined ? -1 : parseInt((v||"0").replace(/[^0-9]+/g, ''), 10) | ||
} | ||
function gt (v1, v2) { | ||
@@ -203,3 +205,3 @@ v1 = exports.parse(v1) | ||
, tag2 = v2[5] || "" | ||
return tag2 && (!tag1 || tag1 > tag2) | ||
return !!tag2 && (!tag1 || tag1 > tag2) | ||
} | ||
@@ -206,0 +208,0 @@ |
Sorry, the diff of this file is not supported yet
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
14566
310
87