Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

doc: update misc/semver.md

  • Loading branch information...
commit 30b67836b51b68614c9e87dc476c0961d53ec6d4 1 parent 4b51920
@isaacs isaacs authored
Showing with 43 additions and 0 deletions.
  1. +31 −0 doc/misc/semver.md
  2. +12 −0 test/tap/semver-doc.js
View
31 doc/misc/semver.md
@@ -60,9 +60,21 @@ The following range styles are supported:
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.3` := `>=1.2.3-0 <2.0.0-0` "Compatible with 1.2.3". When
+ using caret operators, anything from the specified version (including
+ prerelease) will be supported up to, but not including, the next
+ major version (or its prereleases). `1.5.1` will satisfy `^1.2.3`,
+ while `1.2.2` and `2.0.0-beta` will not.
+* `^0.1.3` := `>=0.1.3-0 <0.2.0-0` "Compatible with 0.1.3". 0.x.x versions are
+ special: the first non-zero component indicates potentially breaking changes,
+ meaning the caret operator matches any version with the same first non-zero
+ component starting at the specified version.
+* `^0.0.2` := `=0.0.2` "Only the version 0.0.2 is considered compatible"
* `~1.2` := `>=1.2.0-0 <1.3.0-0` "Any version starting with 1.2"
+* `^1.2` := `>=1.2.0-0 <2.0.0-0` "Any version compatible 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` := `>=1.0.0-0 <2.0.0-0` "Any version compatible with 1"
* `1.x` := `>=1.0.0-0 <2.0.0-0` "Any version starting with 1"
@@ -109,3 +121,22 @@ strings that they parse.
range.
* maxSatisfying(versions, range): Return the highest version in the list
that satisfies the range, or null if none of them do.
+* gtr(version, range): Return true if version is greater than all the
+ versions possible in the range.
+* ltr(version, range): Return true if version is less than all the
+ versions possible in the range.
+* outside(version, range, hilo): Return true if the version is outside
+ the bounds of the range in either the high or low direction. The
+ `hilo` argument must be either the string `'>'` or `'<'`. (This is
+ the function called by `gtr` and `ltr`.)
+
+Note that, since ranges may be non-contiguous, a version might not be
+greater than a range, less than a range, *or* satisfy a range! For
+example, the range `1.2 <1.2.9 || >2.0.0` would have a hole from `1.2.9`
+until `2.0.0`, so the version `1.2.10` would not be greater than the
+range (because 2.0.1 satisfies, which is higher), nor less than the
+range (since 1.2.8 satisfies, which is lower), and it also does not
+satisfy the range.
+
+If you want to know if a version satisfies or does not satisfy a
+range, use the `satisfies(version, range)` function.
View
12 test/tap/semver-doc.js
@@ -0,0 +1,12 @@
+var test = require("tap").test
+
+test("semver doc is up to date", function(t) {
+ var path = require("path")
+ var moddoc = path.join(__dirname, "../../node_modules/semver/README.md")
+ var mydoc = path.join(__dirname, "../../doc/misc/semver.md")
+ var fs = require("fs")
+ var mod = fs.readFileSync(moddoc, "utf8").replace(/semver\(1\)/, 'semver(7)')
+ var my = fs.readFileSync(mydoc, "utf8")
+ t.equal(my, mod)
+ t.end()
+})
Please sign in to comment.
Something went wrong with that request. Please try again.