The data contained in this repository can be downloaded to your computer using one of several clients.
Please see the documentation of your version control software client for more information.

Please select the desired protocol below to get the URL.

This URL has Read-Only access.

Statistics
| Branch: | Revision:

main_repo / deps / npm / html / doc / semver.html @ 5aef65a9

History | View | Annotate | Download (6.05 KB)

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="../doc/semver.html">semver</a></h1> <p>The semantic versioner for npm</p>
10

    
11
<h2 id="SYNOPSIS">SYNOPSIS</h2>
12

    
13
<p>The npm semantic versioning utility.</p>
14

    
15
<h2 id="DESCRIPTION">DESCRIPTION</h2>
16

    
17
<p>As a node module:</p>
18

    
19
<pre><code>$ npm install semver
20

    
21
semver.valid(&#39;1.2.3&#39;) // &#39;1.2.3&#39;
22
semver.valid(&#39;a.b.c&#39;) // null
23
semver.clean(&#39;  =v1.2.3   &#39;) // &#39;1.2.3&#39;
24
semver.satisfies(&#39;1.2.3&#39;, &#39;1.x || &gt;=2.5.0 || 5.0.0 - 7.2.3&#39;) // true
25
semver.gt(&#39;1.2.3&#39;, &#39;9.8.7&#39;) // false
26
semver.lt(&#39;1.2.3&#39;, &#39;9.8.7&#39;) // true</code></pre>
27

    
28
<p>As a command-line utility:</p>
29

    
30
<pre><code>$ npm install semver -g
31
$ semver -h
32

    
33
Usage: semver -v &lt;version&gt; [-r &lt;range&gt;]
34
Test if version(s) satisfy the supplied range(s),
35
and sort them.
36

    
37
Multiple versions or ranges may be supplied.
38

    
39
Program exits successfully if any valid version satisfies
40
all supplied ranges, and prints all satisfying versions.
41

    
42
If no versions are valid, or ranges are not satisfied,
43
then exits failure.
44

    
45
Versions are printed in ascending order, so supplying
46
multiple versions to the utility will just sort them.</code></pre>
47

    
48
<h2 id="Versions">Versions</h2>
49

    
50
<p>A version is the following things, in this order:</p>
51

    
52
<ul><li>a number (Major)</li><li>a period</li><li>a number (minor)</li><li>a period</li><li>a number (patch)</li><li>OPTIONAL: a hyphen, followed by a number (build)</li><li>OPTIONAL: a collection of pretty much any non-whitespace characters
53
(tag)</li></ul>
54

    
55
<p>A leading <code>&quot;=&quot;</code> or <code>&quot;v&quot;</code> character is stripped off and ignored.</p>
56

    
57
<h2 id="Comparisons">Comparisons</h2>
58

    
59
<p>The ordering of versions is done using the following algorithm, given
60
two versions and asked to find the greater of the two:</p>
61

    
62
<ul><li>If the majors are numerically different, then take the one
63
with a bigger major number. <code>2.3.4 &gt; 1.3.4</code></li><li>If the minors are numerically different, then take the one
64
with the bigger minor number. <code>2.3.4 &gt; 2.2.4</code></li><li>If the patches are numerically different, then take the one with the
65
bigger patch number. <code>2.3.4 &gt; 2.3.3</code></li><li>If only one of them has a build number, then take the one with the
66
build number.  <code>2.3.4-0 &gt; 2.3.4</code></li><li>If they both have build numbers, and the build numbers are numerically
67
different, then take the one with the bigger build number.
68
<code>2.3.4-10 &gt; 2.3.4-9</code></li><li>If only one of them has a tag, then take the one without the tag.
69
<code>2.3.4 &gt; 2.3.4-beta</code></li><li>If they both have tags, then take the one with the lexicographically
70
larger tag.  <code>2.3.4-beta &gt; 2.3.4-alpha</code></li><li>At this point, they&#39;re equal.</li></ul>
71

    
72
<h2 id="Ranges">Ranges</h2>
73

    
74
<p>The following range styles are supported:</p>
75

    
76
<ul><li><code>&gt;1.2.3</code> Greater than a specific version.</li><li><code>&lt;1.2.3</code> Less than</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 &lt;1.3.0</code></li><li><code>~1.2</code> := <code>&gt;=1.2.0 &lt;1.3.0</code></li><li><code>~1</code> := <code>&gt;=1.0.0 &lt;2.0.0</code></li><li><code>1.2.x</code> := <code>&gt;=1.2.0 &lt;1.3.0</code></li><li><code>1.x</code> := <code>&gt;=1.0.0 &lt;2.0.0</code></li></ul>
77

    
78
<p>Ranges can be joined with either a space (which implies &quot;and&quot;) or a
79
<code>||</code> (which implies &quot;or&quot;).</p>
80

    
81
<h2 id="Functions">Functions</h2>
82

    
83
<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
84
(major, minor, patch, or build), or null if it&#39;s not valid.</li></ul>
85

    
86
<h3 id="Comparison">Comparison</h3>
87

    
88
<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,
89
even if they&#39;re not the exact same string.  You already know how to
90
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
91
the corresponding function above.  <code>&quot;===&quot;</code> and <code>&quot;!==&quot;</code> do simple
92
string comparison, but are included for completeness.  Throws if an
93
invalid comparison string is provided.</li><li>compare(v1, v2): Return 0 if v1 == v2, or 1 if v1 is greater, or -1 if
94
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
95
in descending order when passed to Array.sort().</li></ul>
96

    
97
<h3 id="Ranges">Ranges</h3>
98

    
99
<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
100
range.</li><li>maxSatisfying(versions, range): Return the highest version in the list
101
that satisfies the range, or null if none of them do.</li></ul>
102

    
103
<h2 id="SEE-ALSO">SEE ALSO</h2>
104

    
105
<ul><li><a href="../doc/json.html">json(1)</a></li></ul>
106
</div>
107
<p id="footer">semver &mdash; npm@1.2.10</p>
108
<script>
109
;(function () {
110
var wrapper = document.getElementById("wrapper")
111
var els = Array.prototype.slice.call(wrapper.getElementsByTagName("*"), 0)
112
  .filter(function (el) {
113
    return el.parentNode === wrapper
114
        && el.tagName.match(/H[1-6]/)
115
        && el.id
116
  })
117
var l = 2
118
  , toc = document.createElement("ul")
119
toc.innerHTML = els.map(function (el) {
120
  var i = el.tagName.charAt(1)
121
    , out = ""
122
  while (i > l) {
123
    out += "<ul>"
124
    l ++
125
  }
126
  while (i < l) {
127
    out += "</ul>"
128
    l --
129
  }
130
  out += "<li><a href='#" + el.id + "'>" +
131
    ( el.innerText || el.text || el.innerHTML)
132
    + "</a>"
133
  return out
134
}).join("\n")
135
toc.id = "toc"
136
document.body.appendChild(toc)
137
})()
138
</script>
139
</body></html>