npm: Upgrade to 1.3.19
[platform/upstream/nodejs.git] / deps / npm / html / doc / misc / semver.html
1 <!doctype html>
2 <html>
3   <title>semver</title>
4   <meta http-equiv="content-type" value="text/html;utf-8">
5   <link rel="stylesheet" type="text/css" href="../../static/style.css">
6
7   <body>
8     <div id="wrapper">
9 <h1><a href="../misc/semver.html">semver</a></h1> <p>The semantic versioner for npm</p>
10
11 <h2 id="Usage">Usage</h2>
12
13 <pre><code>$ npm install semver
14
15 semver.valid(&#39;1.2.3&#39;) // &#39;1.2.3&#39;
16 semver.valid(&#39;a.b.c&#39;) // null
17 semver.clean(&#39;  =v1.2.3   &#39;) // &#39;1.2.3&#39;
18 semver.satisfies(&#39;1.2.3&#39;, &#39;1.x || &gt;=2.5.0 || 5.0.0 - 7.2.3&#39;) // true
19 semver.gt(&#39;1.2.3&#39;, &#39;9.8.7&#39;) // false
20 semver.lt(&#39;1.2.3&#39;, &#39;9.8.7&#39;) // true</code></pre>
21
22 <p>As a command-line utility:</p>
23
24 <pre><code>$ semver -h
25
26 Usage: semver &lt;version&gt; [&lt;version&gt; [...]] [-r &lt;range&gt; | -i &lt;inc&gt; | -d &lt;dec&gt;]
27 Test if version(s) satisfy the supplied range(s), and sort them.
28
29 Multiple versions or ranges may be supplied, unless increment
30 or decrement options are specified.  In that case, only a single
31 version may be used, and it is incremented by the specified level
32
33 Program exits successfully if any valid version satisfies
34 all supplied ranges, and prints all satisfying versions.
35
36 If no versions are valid, or ranges are not satisfied,
37 then exits failure.
38
39 Versions are printed in ascending order, so supplying
40 multiple versions to the utility will just sort them.</code></pre>
41
42 <h2 id="Versions">Versions</h2>
43
44 <p>A &quot;version&quot; is described by the v2.0.0 specification found at
45 <a href="http://semver.org/">http://semver.org/</a>.</p>
46
47 <p>A leading <code>&quot;=&quot;</code> or <code>&quot;v&quot;</code> character is stripped off and ignored.</p>
48
49 <h2 id="Ranges">Ranges</h2>
50
51 <p>The following range styles are supported:</p>
52
53 <ul><li><code>1.2.3</code> A specific version.  When nothing else will do.  Note that
54 build metadata is still ignored, so <code>1.2.3+build2012</code> will satisfy
55 this range.</li><li><code>&gt;1.2.3</code> Greater than a specific version.</li><li><code>&lt;1.2.3</code> Less than a specific version.  If there is no prerelease
56 tag on the version range, then no prerelease version will be allowed
57 either, even though these are technically &quot;less than&quot;.</li><li><code>&gt;=1.2.3</code> Greater than or equal to.  Note that prerelease versions
58 are NOT equal to their &quot;normal&quot; equivalents, so <code>1.2.3-beta</code> will
59 not satisfy this range, but <code>2.3.0-beta</code> will.</li><li><code>&lt;=1.2.3</code> Less than or equal to.  In this case, prerelease versions
60 ARE allowed, so <code>1.2.3-beta</code> would satisfy.</li><li><code>1.2.3 - 2.3.4</code> := <code>&gt;=1.2.3 &lt;=2.3.4</code></li><li><code>~1.2.3</code> := <code>&gt;=1.2.3-0 &lt;1.3.0-0</code>  &quot;Reasonably close to 1.2.3&quot;.  When
61 using tilde operators, prerelease versions are supported as well,
62 but a prerelease of the next significant digit will NOT be
63 satisfactory, so <code>1.3.0-beta</code> will not satisfy <code>~1.2.3</code>.</li><li><code>~1.2</code> := <code>&gt;=1.2.0-0 &lt;1.3.0-0</code> &quot;Any version starting with 1.2&quot;</li><li><code>1.2.x</code> := <code>&gt;=1.2.0-0 &lt;1.3.0-0</code> &quot;Any version starting with 1.2&quot;</li><li><code>~1</code> := <code>&gt;=1.0.0-0 &lt;2.0.0-0</code> &quot;Any version starting with 1&quot;</li><li><code>1.x</code> := <code>&gt;=1.0.0-0 &lt;2.0.0-0</code> &quot;Any version starting with 1&quot;</li></ul>
64
65 <p>Ranges can be joined with either a space (which implies &quot;and&quot;) or a
66 <code>||</code> (which implies &quot;or&quot;).</p>
67
68 <h2 id="Functions">Functions</h2>
69
70 <p>All methods and classes take a final <code>loose</code> boolean argument that, if
71 true, will be more forgiving about not-quite-valid semver strings.
72 The resulting output will always be 100% strict, of course.</p>
73
74 <p>Strict-mode Comparators and Ranges will be strict about the SemVer
75 strings that they parse.</p>
76
77 <ul><li>valid(v): Return the parsed version, or null if it&#39;s not valid.</li><li>inc(v, release): Return the version incremented by the release type
78 (major, minor, patch, or prerelease), or null if it&#39;s not valid.</li></ul>
79
80 <h3 id="Comparison">Comparison</h3>
81
82 <ul><li>gt(v1, v2): <code>v1 &gt; v2</code></li><li>gte(v1, v2): <code>v1 &gt;= v2</code></li><li>lt(v1, v2): <code>v1 &lt; v2</code></li><li>lte(v1, v2): <code>v1 &lt;= v2</code></li><li>eq(v1, v2): <code>v1 == v2</code> This is true if they&#39;re logically equivalent,
83 even if they&#39;re not the exact same string.  You already know how to
84 compare strings.</li><li>neq(v1, v2): <code>v1 != v2</code> The opposite of eq.</li><li>cmp(v1, comparator, v2): Pass in a comparison string, and it&#39;ll call
85 the corresponding function above.  <code>&quot;===&quot;</code> and <code>&quot;!==&quot;</code> do simple
86 string comparison, but are included for completeness.  Throws if an
87 invalid comparison string is provided.</li><li>compare(v1, v2): Return 0 if v1 == v2, or 1 if v1 is greater, or -1 if
88 v2 is greater.  Sorts in ascending order if passed to Array.sort().</li><li>rcompare(v1, v2): The reverse of compare.  Sorts an array of versions
89 in descending order when passed to Array.sort().</li></ul>
90
91 <h3 id="Ranges">Ranges</h3>
92
93 <ul><li>validRange(range): Return the valid range or null if it&#39;s not valid</li><li>satisfies(version, range): Return true if the version satisfies the
94 range.</li><li>maxSatisfying(versions, range): Return the highest version in the list
95 that satisfies the range, or null if none of them do.</li></ul>
96 </div>
97 <p id="footer">semver &mdash; npm@1.3.19</p>
98 <script>
99 ;(function () {
100 var wrapper = document.getElementById("wrapper")
101 var els = Array.prototype.slice.call(wrapper.getElementsByTagName("*"), 0)
102   .filter(function (el) {
103     return el.parentNode === wrapper
104         && el.tagName.match(/H[1-6]/)
105         && el.id
106   })
107 var l = 2
108   , toc = document.createElement("ul")
109 toc.innerHTML = els.map(function (el) {
110   var i = el.tagName.charAt(1)
111     , out = ""
112   while (i > l) {
113     out += "<ul>"
114     l ++
115   }
116   while (i < l) {
117     out += "</ul>"
118     l --
119   }
120   out += "<li><a href='#" + el.id + "'>" +
121     ( el.innerText || el.text || el.innerHTML)
122     + "</a>"
123   return out
124 }).join("\n")
125 toc.id = "toc"
126 document.body.appendChild(toc)
127 })()
128 </script>