node-datachannel 0.2.2 → 0.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.
- package/.editorconfig +12 -0
- package/.eslintignore +2 -0
- package/.eslintrc.js +8 -0
- package/.github/FUNDING.yml +2 -0
- package/.github/workflows/build-linux.yml +5 -3
- package/.github/workflows/build-mac.yml +1 -1
- package/.github/workflows/build-win.yml +4 -10
- package/.prettierrc.js +7 -0
- package/CMakeLists.txt +8 -2
- package/README.md +4 -4
- package/lib/datachannel-stream.js +97 -0
- package/lib/index.d.ts +60 -53
- package/lib/index.js +5 -2
- package/node_modules/decompress-response/index.d.ts +14 -21
- package/node_modules/decompress-response/index.js +34 -16
- package/node_modules/decompress-response/license +1 -1
- package/node_modules/decompress-response/package.json +23 -17
- package/node_modules/decompress-response/readme.md +2 -6
- package/node_modules/detect-libc/README.md +124 -42
- package/node_modules/detect-libc/index.d.ts +11 -0
- package/node_modules/detect-libc/lib/detect-libc.js +166 -80
- package/node_modules/detect-libc/lib/process.js +16 -0
- package/node_modules/detect-libc/package.json +20 -19
- package/node_modules/{semver → lru-cache}/LICENSE +0 -0
- package/node_modules/lru-cache/README.md +166 -0
- package/node_modules/lru-cache/index.js +334 -0
- package/node_modules/lru-cache/node_modules/yallist/LICENSE +15 -0
- package/node_modules/lru-cache/node_modules/yallist/README.md +204 -0
- package/node_modules/lru-cache/node_modules/yallist/iterator.js +8 -0
- package/node_modules/lru-cache/node_modules/yallist/package.json +65 -0
- package/node_modules/lru-cache/node_modules/yallist/yallist.js +426 -0
- package/node_modules/lru-cache/package.json +75 -0
- package/node_modules/mimic-response/index.d.ts +2 -2
- package/node_modules/mimic-response/index.js +41 -2
- package/node_modules/mimic-response/package.json +17 -17
- package/node_modules/mimic-response/readme.md +22 -1
- package/node_modules/minimist/index.js +6 -2
- package/node_modules/minimist/package.json +10 -10
- package/node_modules/minimist/readme.markdown +4 -1
- package/node_modules/minimist/test/proto.js +16 -0
- package/node_modules/node-abi/.circleci/config.yml +63 -0
- package/node_modules/node-abi/.releaserc.json +9 -0
- package/node_modules/node-abi/abi_registry.json +45 -3
- package/node_modules/node-abi/index.js +5 -2
- package/node_modules/node-abi/node_modules/semver/CHANGELOG.md +111 -0
- package/node_modules/node-abi/node_modules/semver/LICENSE +15 -0
- package/node_modules/{semver → node-abi/node_modules/semver}/README.md +180 -26
- package/node_modules/node-abi/node_modules/semver/bin/semver.js +173 -0
- package/node_modules/node-abi/node_modules/semver/classes/comparator.js +135 -0
- package/node_modules/node-abi/node_modules/semver/classes/index.js +5 -0
- package/node_modules/node-abi/node_modules/semver/classes/range.js +510 -0
- package/node_modules/node-abi/node_modules/semver/classes/semver.js +287 -0
- package/node_modules/node-abi/node_modules/semver/functions/clean.js +6 -0
- package/node_modules/node-abi/node_modules/semver/functions/cmp.js +48 -0
- package/node_modules/node-abi/node_modules/semver/functions/coerce.js +51 -0
- package/node_modules/node-abi/node_modules/semver/functions/compare-build.js +7 -0
- package/node_modules/node-abi/node_modules/semver/functions/compare-loose.js +3 -0
- package/node_modules/node-abi/node_modules/semver/functions/compare.js +5 -0
- package/node_modules/node-abi/node_modules/semver/functions/diff.js +23 -0
- package/node_modules/node-abi/node_modules/semver/functions/eq.js +3 -0
- package/node_modules/node-abi/node_modules/semver/functions/gt.js +3 -0
- package/node_modules/node-abi/node_modules/semver/functions/gte.js +3 -0
- package/node_modules/node-abi/node_modules/semver/functions/inc.js +15 -0
- package/node_modules/node-abi/node_modules/semver/functions/lt.js +3 -0
- package/node_modules/node-abi/node_modules/semver/functions/lte.js +3 -0
- package/node_modules/node-abi/node_modules/semver/functions/major.js +3 -0
- package/node_modules/node-abi/node_modules/semver/functions/minor.js +3 -0
- package/node_modules/node-abi/node_modules/semver/functions/neq.js +3 -0
- package/node_modules/node-abi/node_modules/semver/functions/parse.js +33 -0
- package/node_modules/node-abi/node_modules/semver/functions/patch.js +3 -0
- package/node_modules/node-abi/node_modules/semver/functions/prerelease.js +6 -0
- package/node_modules/node-abi/node_modules/semver/functions/rcompare.js +3 -0
- package/node_modules/node-abi/node_modules/semver/functions/rsort.js +3 -0
- package/node_modules/node-abi/node_modules/semver/functions/satisfies.js +10 -0
- package/node_modules/node-abi/node_modules/semver/functions/sort.js +3 -0
- package/node_modules/node-abi/node_modules/semver/functions/valid.js +6 -0
- package/node_modules/node-abi/node_modules/semver/index.js +48 -0
- package/node_modules/node-abi/node_modules/semver/internal/constants.js +17 -0
- package/node_modules/node-abi/node_modules/semver/internal/debug.js +9 -0
- package/node_modules/node-abi/node_modules/semver/internal/identifiers.js +23 -0
- package/node_modules/node-abi/node_modules/semver/internal/parse-options.js +11 -0
- package/node_modules/node-abi/node_modules/semver/internal/re.js +182 -0
- package/node_modules/{semver → node-abi/node_modules/semver}/package.json +32 -23
- package/node_modules/node-abi/node_modules/semver/preload.js +2 -0
- package/node_modules/{semver → node-abi/node_modules/semver}/range.bnf +0 -0
- package/node_modules/node-abi/node_modules/semver/ranges/gtr.js +4 -0
- package/node_modules/node-abi/node_modules/semver/ranges/intersects.js +7 -0
- package/node_modules/node-abi/node_modules/semver/ranges/ltr.js +4 -0
- package/node_modules/node-abi/node_modules/semver/ranges/max-satisfying.js +25 -0
- package/node_modules/node-abi/node_modules/semver/ranges/min-satisfying.js +24 -0
- package/node_modules/node-abi/node_modules/semver/ranges/min-version.js +60 -0
- package/node_modules/node-abi/node_modules/semver/ranges/outside.js +80 -0
- package/node_modules/node-abi/node_modules/semver/ranges/simplify.js +44 -0
- package/node_modules/node-abi/node_modules/semver/ranges/subset.js +222 -0
- package/node_modules/node-abi/node_modules/semver/ranges/to-comparators.js +8 -0
- package/node_modules/node-abi/node_modules/semver/ranges/valid.js +11 -0
- package/node_modules/node-abi/package.json +21 -17
- package/node_modules/node-abi/test/index.js +7 -15
- package/node_modules/prebuild-install/CHANGELOG.md +24 -7
- package/node_modules/prebuild-install/README.md +24 -4
- package/node_modules/prebuild-install/asset.js +10 -10
- package/node_modules/prebuild-install/bin.js +13 -13
- package/node_modules/prebuild-install/download.js +22 -22
- package/node_modules/prebuild-install/log.js +4 -4
- package/node_modules/prebuild-install/package.json +18 -19
- package/node_modules/prebuild-install/proxy.js +10 -10
- package/node_modules/prebuild-install/rc.js +12 -12
- package/node_modules/prebuild-install/util.js +14 -14
- package/node_modules/simple-get/.github/dependabot.yml +15 -0
- package/node_modules/simple-get/.github/workflows/ci.yml +23 -0
- package/node_modules/simple-get/README.md +17 -3
- package/node_modules/simple-get/index.js +9 -0
- package/node_modules/simple-get/package.json +27 -13
- package/package.json +15 -6
- package/src/data-channel-wrapper.cpp +56 -22
- package/src/data-channel-wrapper.h +3 -0
- package/src/media-audio-wrapper.cpp +7 -7
- package/src/media-track-wrapper.cpp +40 -21
- package/src/media-track-wrapper.h +2 -0
- package/src/media-video-wrapper.cpp +5 -5
- package/src/peer-connection-wrapper.cpp +48 -27
- package/src/peer-connection-wrapper.h +2 -0
- package/test/connectivity.js +6 -6
- package/test/test.js +46 -1
- package/node_modules/detect-libc/.npmignore +0 -7
- package/node_modules/detect-libc/bin/detect-libc.js +0 -18
- package/node_modules/node-abi/.travis.yml +0 -17
- package/node_modules/semver/CHANGELOG.md +0 -39
- package/node_modules/semver/bin/semver +0 -160
- package/node_modules/semver/semver.js +0 -1483
|
@@ -4,7 +4,7 @@ semver(1) -- The semantic versioner for npm
|
|
|
4
4
|
## Install
|
|
5
5
|
|
|
6
6
|
```bash
|
|
7
|
-
npm install
|
|
7
|
+
npm install semver
|
|
8
8
|
````
|
|
9
9
|
|
|
10
10
|
## Usage
|
|
@@ -25,6 +25,63 @@ semver.valid(semver.coerce('v2')) // '2.0.0'
|
|
|
25
25
|
semver.valid(semver.coerce('42.6.7.9.3-alpha')) // '42.6.7'
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
+
You can also just load the module for the function that you care about, if
|
|
29
|
+
you'd like to minimize your footprint.
|
|
30
|
+
|
|
31
|
+
```js
|
|
32
|
+
// load the whole API at once in a single object
|
|
33
|
+
const semver = require('semver')
|
|
34
|
+
|
|
35
|
+
// or just load the bits you need
|
|
36
|
+
// all of them listed here, just pick and choose what you want
|
|
37
|
+
|
|
38
|
+
// classes
|
|
39
|
+
const SemVer = require('semver/classes/semver')
|
|
40
|
+
const Comparator = require('semver/classes/comparator')
|
|
41
|
+
const Range = require('semver/classes/range')
|
|
42
|
+
|
|
43
|
+
// functions for working with versions
|
|
44
|
+
const semverParse = require('semver/functions/parse')
|
|
45
|
+
const semverValid = require('semver/functions/valid')
|
|
46
|
+
const semverClean = require('semver/functions/clean')
|
|
47
|
+
const semverInc = require('semver/functions/inc')
|
|
48
|
+
const semverDiff = require('semver/functions/diff')
|
|
49
|
+
const semverMajor = require('semver/functions/major')
|
|
50
|
+
const semverMinor = require('semver/functions/minor')
|
|
51
|
+
const semverPatch = require('semver/functions/patch')
|
|
52
|
+
const semverPrerelease = require('semver/functions/prerelease')
|
|
53
|
+
const semverCompare = require('semver/functions/compare')
|
|
54
|
+
const semverRcompare = require('semver/functions/rcompare')
|
|
55
|
+
const semverCompareLoose = require('semver/functions/compare-loose')
|
|
56
|
+
const semverCompareBuild = require('semver/functions/compare-build')
|
|
57
|
+
const semverSort = require('semver/functions/sort')
|
|
58
|
+
const semverRsort = require('semver/functions/rsort')
|
|
59
|
+
|
|
60
|
+
// low-level comparators between versions
|
|
61
|
+
const semverGt = require('semver/functions/gt')
|
|
62
|
+
const semverLt = require('semver/functions/lt')
|
|
63
|
+
const semverEq = require('semver/functions/eq')
|
|
64
|
+
const semverNeq = require('semver/functions/neq')
|
|
65
|
+
const semverGte = require('semver/functions/gte')
|
|
66
|
+
const semverLte = require('semver/functions/lte')
|
|
67
|
+
const semverCmp = require('semver/functions/cmp')
|
|
68
|
+
const semverCoerce = require('semver/functions/coerce')
|
|
69
|
+
|
|
70
|
+
// working with ranges
|
|
71
|
+
const semverSatisfies = require('semver/functions/satisfies')
|
|
72
|
+
const semverMaxSatisfying = require('semver/ranges/max-satisfying')
|
|
73
|
+
const semverMinSatisfying = require('semver/ranges/min-satisfying')
|
|
74
|
+
const semverToComparators = require('semver/ranges/to-comparators')
|
|
75
|
+
const semverMinVersion = require('semver/ranges/min-version')
|
|
76
|
+
const semverValidRange = require('semver/ranges/valid')
|
|
77
|
+
const semverOutside = require('semver/ranges/outside')
|
|
78
|
+
const semverGtr = require('semver/ranges/gtr')
|
|
79
|
+
const semverLtr = require('semver/ranges/ltr')
|
|
80
|
+
const semverIntersects = require('semver/ranges/intersects')
|
|
81
|
+
const simplifyRange = require('semver/ranges/simplify')
|
|
82
|
+
const rangeSubset = require('semver/ranges/subset')
|
|
83
|
+
```
|
|
84
|
+
|
|
28
85
|
As a command-line utility:
|
|
29
86
|
|
|
30
87
|
```
|
|
@@ -60,6 +117,12 @@ Options:
|
|
|
60
117
|
Coerce a string into SemVer if possible
|
|
61
118
|
(does not imply --loose)
|
|
62
119
|
|
|
120
|
+
--rtl
|
|
121
|
+
Coerce version strings right to left
|
|
122
|
+
|
|
123
|
+
--ltr
|
|
124
|
+
Coerce version strings left to right (default)
|
|
125
|
+
|
|
63
126
|
Program exits successfully if any valid version satisfies
|
|
64
127
|
all supplied ranges, and prints all satisfying versions.
|
|
65
128
|
|
|
@@ -193,8 +256,8 @@ inclusive range, then all versions that start with the supplied parts
|
|
|
193
256
|
of the tuple are accepted, but nothing that would be greater than the
|
|
194
257
|
provided tuple parts.
|
|
195
258
|
|
|
196
|
-
* `1.2.3 - 2.3` := `>=1.2.3 <2.4.0`
|
|
197
|
-
* `1.2.3 - 2` := `>=1.2.3 <3.0.0`
|
|
259
|
+
* `1.2.3 - 2.3` := `>=1.2.3 <2.4.0-0`
|
|
260
|
+
* `1.2.3 - 2` := `>=1.2.3 <3.0.0-0`
|
|
198
261
|
|
|
199
262
|
#### X-Ranges `1.2.x` `1.X` `1.2.*` `*`
|
|
200
263
|
|
|
@@ -202,28 +265,28 @@ Any of `X`, `x`, or `*` may be used to "stand in" for one of the
|
|
|
202
265
|
numeric values in the `[major, minor, patch]` tuple.
|
|
203
266
|
|
|
204
267
|
* `*` := `>=0.0.0` (Any version satisfies)
|
|
205
|
-
* `1.x` := `>=1.0.0 <2.0.0` (Matching major version)
|
|
206
|
-
* `1.2.x` := `>=1.2.0 <1.3.0` (Matching major and minor versions)
|
|
268
|
+
* `1.x` := `>=1.0.0 <2.0.0-0` (Matching major version)
|
|
269
|
+
* `1.2.x` := `>=1.2.0 <1.3.0-0` (Matching major and minor versions)
|
|
207
270
|
|
|
208
271
|
A partial version range is treated as an X-Range, so the special
|
|
209
272
|
character is in fact optional.
|
|
210
273
|
|
|
211
274
|
* `""` (empty string) := `*` := `>=0.0.0`
|
|
212
|
-
* `1` := `1.x.x` := `>=1.0.0 <2.0.0`
|
|
213
|
-
* `1.2` := `1.2.x` := `>=1.2.0 <1.3.0`
|
|
275
|
+
* `1` := `1.x.x` := `>=1.0.0 <2.0.0-0`
|
|
276
|
+
* `1.2` := `1.2.x` := `>=1.2.0 <1.3.0-0`
|
|
214
277
|
|
|
215
278
|
#### Tilde Ranges `~1.2.3` `~1.2` `~1`
|
|
216
279
|
|
|
217
280
|
Allows patch-level changes if a minor version is specified on the
|
|
218
281
|
comparator. Allows minor-level changes if not.
|
|
219
282
|
|
|
220
|
-
* `~1.2.3` := `>=1.2.3 <1.(2+1).0` := `>=1.2.3 <1.3.0`
|
|
221
|
-
* `~1.2` := `>=1.2.0 <1.(2+1).0` := `>=1.2.0 <1.3.0` (Same as `1.2.x`)
|
|
222
|
-
* `~1` := `>=1.0.0 <(1+1).0.0` := `>=1.0.0 <2.0.0` (Same as `1.x`)
|
|
223
|
-
* `~0.2.3` := `>=0.2.3 <0.(2+1).0` := `>=0.2.3 <0.3.0`
|
|
224
|
-
* `~0.2` := `>=0.2.0 <0.(2+1).0` := `>=0.2.0 <0.3.0` (Same as `0.2.x`)
|
|
225
|
-
* `~0` := `>=0.0.0 <(0+1).0.0` := `>=0.0.0 <1.0.0` (Same as `0.x`)
|
|
226
|
-
* `~1.2.3-beta.2` := `>=1.2.3-beta.2 <1.3.0` Note that prereleases in
|
|
283
|
+
* `~1.2.3` := `>=1.2.3 <1.(2+1).0` := `>=1.2.3 <1.3.0-0`
|
|
284
|
+
* `~1.2` := `>=1.2.0 <1.(2+1).0` := `>=1.2.0 <1.3.0-0` (Same as `1.2.x`)
|
|
285
|
+
* `~1` := `>=1.0.0 <(1+1).0.0` := `>=1.0.0 <2.0.0-0` (Same as `1.x`)
|
|
286
|
+
* `~0.2.3` := `>=0.2.3 <0.(2+1).0` := `>=0.2.3 <0.3.0-0`
|
|
287
|
+
* `~0.2` := `>=0.2.0 <0.(2+1).0` := `>=0.2.0 <0.3.0-0` (Same as `0.2.x`)
|
|
288
|
+
* `~0` := `>=0.0.0 <(0+1).0.0` := `>=0.0.0 <1.0.0-0` (Same as `0.x`)
|
|
289
|
+
* `~1.2.3-beta.2` := `>=1.2.3-beta.2 <1.3.0-0` Note that prereleases in
|
|
227
290
|
the `1.2.3` version will be allowed, if they are greater than or
|
|
228
291
|
equal to `beta.2`. So, `1.2.3-beta.4` would be allowed, but
|
|
229
292
|
`1.2.4-beta.2` would not, because it is a prerelease of a
|
|
@@ -231,7 +294,7 @@ comparator. Allows minor-level changes if not.
|
|
|
231
294
|
|
|
232
295
|
#### Caret Ranges `^1.2.3` `^0.2.5` `^0.0.4`
|
|
233
296
|
|
|
234
|
-
Allows changes that do not modify the left-most non-zero
|
|
297
|
+
Allows changes that do not modify the left-most non-zero element in the
|
|
235
298
|
`[major, minor, patch]` tuple. In other words, this allows patch and
|
|
236
299
|
minor updates for versions `1.0.0` and above, patch updates for
|
|
237
300
|
versions `0.X >=0.1.0`, and *no* updates for versions `0.0.X`.
|
|
@@ -245,15 +308,15 @@ However, it presumes that there will *not* be breaking changes between
|
|
|
245
308
|
`0.2.4` and `0.2.5`. It allows for changes that are presumed to be
|
|
246
309
|
additive (but non-breaking), according to commonly observed practices.
|
|
247
310
|
|
|
248
|
-
* `^1.2.3` := `>=1.2.3 <2.0.0`
|
|
249
|
-
* `^0.2.3` := `>=0.2.3 <0.3.0`
|
|
250
|
-
* `^0.0.3` := `>=0.0.3 <0.0.4`
|
|
251
|
-
* `^1.2.3-beta.2` := `>=1.2.3-beta.2 <2.0.0` Note that prereleases in
|
|
311
|
+
* `^1.2.3` := `>=1.2.3 <2.0.0-0`
|
|
312
|
+
* `^0.2.3` := `>=0.2.3 <0.3.0-0`
|
|
313
|
+
* `^0.0.3` := `>=0.0.3 <0.0.4-0`
|
|
314
|
+
* `^1.2.3-beta.2` := `>=1.2.3-beta.2 <2.0.0-0` Note that prereleases in
|
|
252
315
|
the `1.2.3` version will be allowed, if they are greater than or
|
|
253
316
|
equal to `beta.2`. So, `1.2.3-beta.4` would be allowed, but
|
|
254
317
|
`1.2.4-beta.2` would not, because it is a prerelease of a
|
|
255
318
|
different `[major, minor, patch]` tuple.
|
|
256
|
-
* `^0.0.3-beta` := `>=0.0.3-beta <0.0.4` Note that prereleases in the
|
|
319
|
+
* `^0.0.3-beta` := `>=0.0.3-beta <0.0.4-0` Note that prereleases in the
|
|
257
320
|
`0.0.3` version *only* will be allowed, if they are greater than or
|
|
258
321
|
equal to `beta`. So, `0.0.3-pr.2` would be allowed.
|
|
259
322
|
|
|
@@ -261,16 +324,16 @@ When parsing caret ranges, a missing `patch` value desugars to the
|
|
|
261
324
|
number `0`, but will allow flexibility within that value, even if the
|
|
262
325
|
major and minor versions are both `0`.
|
|
263
326
|
|
|
264
|
-
* `^1.2.x` := `>=1.2.0 <2.0.0`
|
|
265
|
-
* `^0.0.x` := `>=0.0.0 <0.1.0`
|
|
266
|
-
* `^0.0` := `>=0.0.0 <0.1.0`
|
|
327
|
+
* `^1.2.x` := `>=1.2.0 <2.0.0-0`
|
|
328
|
+
* `^0.0.x` := `>=0.0.0 <0.1.0-0`
|
|
329
|
+
* `^0.0` := `>=0.0.0 <0.1.0-0`
|
|
267
330
|
|
|
268
331
|
A missing `minor` and `patch` values will desugar to zero, but also
|
|
269
332
|
allow flexibility within those values, even if the major version is
|
|
270
333
|
zero.
|
|
271
334
|
|
|
272
|
-
* `^1.x` := `>=1.0.0 <2.0.0`
|
|
273
|
-
* `^0.x` := `>=0.0.0 <1.0.0`
|
|
335
|
+
* `^1.x` := `>=1.0.0 <2.0.0-0`
|
|
336
|
+
* `^0.x` := `>=0.0.0 <1.0.0-0`
|
|
274
337
|
|
|
275
338
|
### Range Grammar
|
|
276
339
|
|
|
@@ -354,6 +417,9 @@ strings that they parse.
|
|
|
354
417
|
`v2` is greater. Sorts in ascending order if passed to `Array.sort()`.
|
|
355
418
|
* `rcompare(v1, v2)`: The reverse of compare. Sorts an array of versions
|
|
356
419
|
in descending order when passed to `Array.sort()`.
|
|
420
|
+
* `compareBuild(v1, v2)`: The same as `compare` but considers `build` when two versions
|
|
421
|
+
are equal. Sorts in ascending order if passed to `Array.sort()`.
|
|
422
|
+
`v2` is greater. Sorts in ascending order if passed to `Array.sort()`.
|
|
357
423
|
* `diff(v1, v2)`: Returns difference between two versions by the release type
|
|
358
424
|
(`major`, `premajor`, `minor`, `preminor`, `patch`, `prepatch`, or `prerelease`),
|
|
359
425
|
or null if the versions are the same.
|
|
@@ -382,6 +448,16 @@ strings that they parse.
|
|
|
382
448
|
`hilo` argument must be either the string `'>'` or `'<'`. (This is
|
|
383
449
|
the function called by `gtr` and `ltr`.)
|
|
384
450
|
* `intersects(range)`: Return true if any of the ranges comparators intersect
|
|
451
|
+
* `simplifyRange(versions, range)`: Return a "simplified" range that
|
|
452
|
+
matches the same items in `versions` list as the range specified. Note
|
|
453
|
+
that it does *not* guarantee that it would match the same versions in all
|
|
454
|
+
cases, only for the set of versions provided. This is useful when
|
|
455
|
+
generating ranges by joining together multiple versions with `||`
|
|
456
|
+
programmatically, to provide the user with something a bit more
|
|
457
|
+
ergonomic. If the provided range is shorter in string-length than the
|
|
458
|
+
generated range, then that is returned.
|
|
459
|
+
* `subset(subRange, superRange)`: Return `true` if the `subRange` range is
|
|
460
|
+
entirely contained by the `superRange` range.
|
|
385
461
|
|
|
386
462
|
Note that, since ranges may be non-contiguous, a version might not be
|
|
387
463
|
greater than a range, less than a range, *or* satisfy a range! For
|
|
@@ -396,7 +472,7 @@ range, use the `satisfies(version, range)` function.
|
|
|
396
472
|
|
|
397
473
|
### Coercion
|
|
398
474
|
|
|
399
|
-
* `coerce(version)`: Coerces a string to semver if possible
|
|
475
|
+
* `coerce(version, options)`: Coerces a string to semver if possible
|
|
400
476
|
|
|
401
477
|
This aims to provide a very forgiving translation of a non-semver string to
|
|
402
478
|
semver. It looks for the first digit in a string, and consumes all
|
|
@@ -410,3 +486,81 @@ coercion is 16 characters; longer components will be ignored
|
|
|
410
486
|
(`10000000000000000.4.7.4` becomes `4.7.4`). The maximum value for any
|
|
411
487
|
semver component is `Number.MAX_SAFE_INTEGER || (2**53 - 1)`; higher value
|
|
412
488
|
components are invalid (`9999999999999999.4.7.4` is likely invalid).
|
|
489
|
+
|
|
490
|
+
If the `options.rtl` flag is set, then `coerce` will return the right-most
|
|
491
|
+
coercible tuple that does not share an ending index with a longer coercible
|
|
492
|
+
tuple. For example, `1.2.3.4` will return `2.3.4` in rtl mode, not
|
|
493
|
+
`4.0.0`. `1.2.3/4` will return `4.0.0`, because the `4` is not a part of
|
|
494
|
+
any other overlapping SemVer tuple.
|
|
495
|
+
|
|
496
|
+
### Clean
|
|
497
|
+
|
|
498
|
+
* `clean(version)`: Clean a string to be a valid semver if possible
|
|
499
|
+
|
|
500
|
+
This will return a cleaned and trimmed semver version. If the provided
|
|
501
|
+
version is not valid a null will be returned. This does not work for
|
|
502
|
+
ranges.
|
|
503
|
+
|
|
504
|
+
ex.
|
|
505
|
+
* `s.clean(' = v 2.1.5foo')`: `null`
|
|
506
|
+
* `s.clean(' = v 2.1.5foo', { loose: true })`: `'2.1.5-foo'`
|
|
507
|
+
* `s.clean(' = v 2.1.5-foo')`: `null`
|
|
508
|
+
* `s.clean(' = v 2.1.5-foo', { loose: true })`: `'2.1.5-foo'`
|
|
509
|
+
* `s.clean('=v2.1.5')`: `'2.1.5'`
|
|
510
|
+
* `s.clean(' =v2.1.5')`: `2.1.5`
|
|
511
|
+
* `s.clean(' 2.1.5 ')`: `'2.1.5'`
|
|
512
|
+
* `s.clean('~1.0.0')`: `null`
|
|
513
|
+
|
|
514
|
+
## Exported Modules
|
|
515
|
+
|
|
516
|
+
<!--
|
|
517
|
+
TODO: Make sure that all of these items are documented (classes aren't,
|
|
518
|
+
eg), and then pull the module name into the documentation for that specific
|
|
519
|
+
thing.
|
|
520
|
+
-->
|
|
521
|
+
|
|
522
|
+
You may pull in just the part of this semver utility that you need, if you
|
|
523
|
+
are sensitive to packing and tree-shaking concerns. The main
|
|
524
|
+
`require('semver')` export uses getter functions to lazily load the parts
|
|
525
|
+
of the API that are used.
|
|
526
|
+
|
|
527
|
+
The following modules are available:
|
|
528
|
+
|
|
529
|
+
* `require('semver')`
|
|
530
|
+
* `require('semver/classes')`
|
|
531
|
+
* `require('semver/classes/comparator')`
|
|
532
|
+
* `require('semver/classes/range')`
|
|
533
|
+
* `require('semver/classes/semver')`
|
|
534
|
+
* `require('semver/functions/clean')`
|
|
535
|
+
* `require('semver/functions/cmp')`
|
|
536
|
+
* `require('semver/functions/coerce')`
|
|
537
|
+
* `require('semver/functions/compare')`
|
|
538
|
+
* `require('semver/functions/compare-build')`
|
|
539
|
+
* `require('semver/functions/compare-loose')`
|
|
540
|
+
* `require('semver/functions/diff')`
|
|
541
|
+
* `require('semver/functions/eq')`
|
|
542
|
+
* `require('semver/functions/gt')`
|
|
543
|
+
* `require('semver/functions/gte')`
|
|
544
|
+
* `require('semver/functions/inc')`
|
|
545
|
+
* `require('semver/functions/lt')`
|
|
546
|
+
* `require('semver/functions/lte')`
|
|
547
|
+
* `require('semver/functions/major')`
|
|
548
|
+
* `require('semver/functions/minor')`
|
|
549
|
+
* `require('semver/functions/neq')`
|
|
550
|
+
* `require('semver/functions/parse')`
|
|
551
|
+
* `require('semver/functions/patch')`
|
|
552
|
+
* `require('semver/functions/prerelease')`
|
|
553
|
+
* `require('semver/functions/rcompare')`
|
|
554
|
+
* `require('semver/functions/rsort')`
|
|
555
|
+
* `require('semver/functions/satisfies')`
|
|
556
|
+
* `require('semver/functions/sort')`
|
|
557
|
+
* `require('semver/functions/valid')`
|
|
558
|
+
* `require('semver/ranges/gtr')`
|
|
559
|
+
* `require('semver/ranges/intersects')`
|
|
560
|
+
* `require('semver/ranges/ltr')`
|
|
561
|
+
* `require('semver/ranges/max-satisfying')`
|
|
562
|
+
* `require('semver/ranges/min-satisfying')`
|
|
563
|
+
* `require('semver/ranges/min-version')`
|
|
564
|
+
* `require('semver/ranges/outside')`
|
|
565
|
+
* `require('semver/ranges/to-comparators')`
|
|
566
|
+
* `require('semver/ranges/valid')`
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Standalone semver comparison program.
|
|
3
|
+
// Exits successfully and prints matching version(s) if
|
|
4
|
+
// any supplied version is valid and passes all tests.
|
|
5
|
+
|
|
6
|
+
const argv = process.argv.slice(2)
|
|
7
|
+
|
|
8
|
+
let versions = []
|
|
9
|
+
|
|
10
|
+
const range = []
|
|
11
|
+
|
|
12
|
+
let inc = null
|
|
13
|
+
|
|
14
|
+
const version = require('../package.json').version
|
|
15
|
+
|
|
16
|
+
let loose = false
|
|
17
|
+
|
|
18
|
+
let includePrerelease = false
|
|
19
|
+
|
|
20
|
+
let coerce = false
|
|
21
|
+
|
|
22
|
+
let rtl = false
|
|
23
|
+
|
|
24
|
+
let identifier
|
|
25
|
+
|
|
26
|
+
const semver = require('../')
|
|
27
|
+
|
|
28
|
+
let reverse = false
|
|
29
|
+
|
|
30
|
+
const options = {}
|
|
31
|
+
|
|
32
|
+
const main = () => {
|
|
33
|
+
if (!argv.length) return help()
|
|
34
|
+
while (argv.length) {
|
|
35
|
+
let a = argv.shift()
|
|
36
|
+
const indexOfEqualSign = a.indexOf('=')
|
|
37
|
+
if (indexOfEqualSign !== -1) {
|
|
38
|
+
a = a.slice(0, indexOfEqualSign)
|
|
39
|
+
argv.unshift(a.slice(indexOfEqualSign + 1))
|
|
40
|
+
}
|
|
41
|
+
switch (a) {
|
|
42
|
+
case '-rv': case '-rev': case '--rev': case '--reverse':
|
|
43
|
+
reverse = true
|
|
44
|
+
break
|
|
45
|
+
case '-l': case '--loose':
|
|
46
|
+
loose = true
|
|
47
|
+
break
|
|
48
|
+
case '-p': case '--include-prerelease':
|
|
49
|
+
includePrerelease = true
|
|
50
|
+
break
|
|
51
|
+
case '-v': case '--version':
|
|
52
|
+
versions.push(argv.shift())
|
|
53
|
+
break
|
|
54
|
+
case '-i': case '--inc': case '--increment':
|
|
55
|
+
switch (argv[0]) {
|
|
56
|
+
case 'major': case 'minor': case 'patch': case 'prerelease':
|
|
57
|
+
case 'premajor': case 'preminor': case 'prepatch':
|
|
58
|
+
inc = argv.shift()
|
|
59
|
+
break
|
|
60
|
+
default:
|
|
61
|
+
inc = 'patch'
|
|
62
|
+
break
|
|
63
|
+
}
|
|
64
|
+
break
|
|
65
|
+
case '--preid':
|
|
66
|
+
identifier = argv.shift()
|
|
67
|
+
break
|
|
68
|
+
case '-r': case '--range':
|
|
69
|
+
range.push(argv.shift())
|
|
70
|
+
break
|
|
71
|
+
case '-c': case '--coerce':
|
|
72
|
+
coerce = true
|
|
73
|
+
break
|
|
74
|
+
case '--rtl':
|
|
75
|
+
rtl = true
|
|
76
|
+
break
|
|
77
|
+
case '--ltr':
|
|
78
|
+
rtl = false
|
|
79
|
+
break
|
|
80
|
+
case '-h': case '--help': case '-?':
|
|
81
|
+
return help()
|
|
82
|
+
default:
|
|
83
|
+
versions.push(a)
|
|
84
|
+
break
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const options = { loose: loose, includePrerelease: includePrerelease, rtl: rtl }
|
|
89
|
+
|
|
90
|
+
versions = versions.map((v) => {
|
|
91
|
+
return coerce ? (semver.coerce(v, options) || { version: v }).version : v
|
|
92
|
+
}).filter((v) => {
|
|
93
|
+
return semver.valid(v)
|
|
94
|
+
})
|
|
95
|
+
if (!versions.length) return fail()
|
|
96
|
+
if (inc && (versions.length !== 1 || range.length)) { return failInc() }
|
|
97
|
+
|
|
98
|
+
for (let i = 0, l = range.length; i < l; i++) {
|
|
99
|
+
versions = versions.filter((v) => {
|
|
100
|
+
return semver.satisfies(v, range[i], options)
|
|
101
|
+
})
|
|
102
|
+
if (!versions.length) return fail()
|
|
103
|
+
}
|
|
104
|
+
return success(versions)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
const failInc = () => {
|
|
109
|
+
console.error('--inc can only be used on a single version with no range')
|
|
110
|
+
fail()
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const fail = () => process.exit(1)
|
|
114
|
+
|
|
115
|
+
const success = () => {
|
|
116
|
+
const compare = reverse ? 'rcompare' : 'compare'
|
|
117
|
+
versions.sort((a, b) => {
|
|
118
|
+
return semver[compare](a, b, options)
|
|
119
|
+
}).map((v) => {
|
|
120
|
+
return semver.clean(v, options)
|
|
121
|
+
}).map((v) => {
|
|
122
|
+
return inc ? semver.inc(v, inc, options, identifier) : v
|
|
123
|
+
}).forEach((v, i, _) => { console.log(v) })
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const help = () => console.log(
|
|
127
|
+
`SemVer ${version}
|
|
128
|
+
|
|
129
|
+
A JavaScript implementation of the https://semver.org/ specification
|
|
130
|
+
Copyright Isaac Z. Schlueter
|
|
131
|
+
|
|
132
|
+
Usage: semver [options] <version> [<version> [...]]
|
|
133
|
+
Prints valid versions sorted by SemVer precedence
|
|
134
|
+
|
|
135
|
+
Options:
|
|
136
|
+
-r --range <range>
|
|
137
|
+
Print versions that match the specified range.
|
|
138
|
+
|
|
139
|
+
-i --increment [<level>]
|
|
140
|
+
Increment a version by the specified level. Level can
|
|
141
|
+
be one of: major, minor, patch, premajor, preminor,
|
|
142
|
+
prepatch, or prerelease. Default level is 'patch'.
|
|
143
|
+
Only one version may be specified.
|
|
144
|
+
|
|
145
|
+
--preid <identifier>
|
|
146
|
+
Identifier to be used to prefix premajor, preminor,
|
|
147
|
+
prepatch or prerelease version increments.
|
|
148
|
+
|
|
149
|
+
-l --loose
|
|
150
|
+
Interpret versions and ranges loosely
|
|
151
|
+
|
|
152
|
+
-p --include-prerelease
|
|
153
|
+
Always include prerelease versions in range matching
|
|
154
|
+
|
|
155
|
+
-c --coerce
|
|
156
|
+
Coerce a string into SemVer if possible
|
|
157
|
+
(does not imply --loose)
|
|
158
|
+
|
|
159
|
+
--rtl
|
|
160
|
+
Coerce version strings right to left
|
|
161
|
+
|
|
162
|
+
--ltr
|
|
163
|
+
Coerce version strings left to right (default)
|
|
164
|
+
|
|
165
|
+
Program exits successfully if any valid version satisfies
|
|
166
|
+
all supplied ranges, and prints all satisfying versions.
|
|
167
|
+
|
|
168
|
+
If no satisfying versions are found, then exits failure.
|
|
169
|
+
|
|
170
|
+
Versions are printed in ascending order, so supplying
|
|
171
|
+
multiple versions to the utility will just sort them.`)
|
|
172
|
+
|
|
173
|
+
main()
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
const ANY = Symbol('SemVer ANY')
|
|
2
|
+
// hoisted class for cyclic dependency
|
|
3
|
+
class Comparator {
|
|
4
|
+
static get ANY () {
|
|
5
|
+
return ANY
|
|
6
|
+
}
|
|
7
|
+
constructor (comp, options) {
|
|
8
|
+
options = parseOptions(options)
|
|
9
|
+
|
|
10
|
+
if (comp instanceof Comparator) {
|
|
11
|
+
if (comp.loose === !!options.loose) {
|
|
12
|
+
return comp
|
|
13
|
+
} else {
|
|
14
|
+
comp = comp.value
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
debug('comparator', comp, options)
|
|
19
|
+
this.options = options
|
|
20
|
+
this.loose = !!options.loose
|
|
21
|
+
this.parse(comp)
|
|
22
|
+
|
|
23
|
+
if (this.semver === ANY) {
|
|
24
|
+
this.value = ''
|
|
25
|
+
} else {
|
|
26
|
+
this.value = this.operator + this.semver.version
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
debug('comp', this)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
parse (comp) {
|
|
33
|
+
const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR]
|
|
34
|
+
const m = comp.match(r)
|
|
35
|
+
|
|
36
|
+
if (!m) {
|
|
37
|
+
throw new TypeError(`Invalid comparator: ${comp}`)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
this.operator = m[1] !== undefined ? m[1] : ''
|
|
41
|
+
if (this.operator === '=') {
|
|
42
|
+
this.operator = ''
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// if it literally is just '>' or '' then allow anything.
|
|
46
|
+
if (!m[2]) {
|
|
47
|
+
this.semver = ANY
|
|
48
|
+
} else {
|
|
49
|
+
this.semver = new SemVer(m[2], this.options.loose)
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
toString () {
|
|
54
|
+
return this.value
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
test (version) {
|
|
58
|
+
debug('Comparator.test', version, this.options.loose)
|
|
59
|
+
|
|
60
|
+
if (this.semver === ANY || version === ANY) {
|
|
61
|
+
return true
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (typeof version === 'string') {
|
|
65
|
+
try {
|
|
66
|
+
version = new SemVer(version, this.options)
|
|
67
|
+
} catch (er) {
|
|
68
|
+
return false
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return cmp(version, this.operator, this.semver, this.options)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
intersects (comp, options) {
|
|
76
|
+
if (!(comp instanceof Comparator)) {
|
|
77
|
+
throw new TypeError('a Comparator is required')
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (!options || typeof options !== 'object') {
|
|
81
|
+
options = {
|
|
82
|
+
loose: !!options,
|
|
83
|
+
includePrerelease: false
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (this.operator === '') {
|
|
88
|
+
if (this.value === '') {
|
|
89
|
+
return true
|
|
90
|
+
}
|
|
91
|
+
return new Range(comp.value, options).test(this.value)
|
|
92
|
+
} else if (comp.operator === '') {
|
|
93
|
+
if (comp.value === '') {
|
|
94
|
+
return true
|
|
95
|
+
}
|
|
96
|
+
return new Range(this.value, options).test(comp.semver)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const sameDirectionIncreasing =
|
|
100
|
+
(this.operator === '>=' || this.operator === '>') &&
|
|
101
|
+
(comp.operator === '>=' || comp.operator === '>')
|
|
102
|
+
const sameDirectionDecreasing =
|
|
103
|
+
(this.operator === '<=' || this.operator === '<') &&
|
|
104
|
+
(comp.operator === '<=' || comp.operator === '<')
|
|
105
|
+
const sameSemVer = this.semver.version === comp.semver.version
|
|
106
|
+
const differentDirectionsInclusive =
|
|
107
|
+
(this.operator === '>=' || this.operator === '<=') &&
|
|
108
|
+
(comp.operator === '>=' || comp.operator === '<=')
|
|
109
|
+
const oppositeDirectionsLessThan =
|
|
110
|
+
cmp(this.semver, '<', comp.semver, options) &&
|
|
111
|
+
(this.operator === '>=' || this.operator === '>') &&
|
|
112
|
+
(comp.operator === '<=' || comp.operator === '<')
|
|
113
|
+
const oppositeDirectionsGreaterThan =
|
|
114
|
+
cmp(this.semver, '>', comp.semver, options) &&
|
|
115
|
+
(this.operator === '<=' || this.operator === '<') &&
|
|
116
|
+
(comp.operator === '>=' || comp.operator === '>')
|
|
117
|
+
|
|
118
|
+
return (
|
|
119
|
+
sameDirectionIncreasing ||
|
|
120
|
+
sameDirectionDecreasing ||
|
|
121
|
+
(sameSemVer && differentDirectionsInclusive) ||
|
|
122
|
+
oppositeDirectionsLessThan ||
|
|
123
|
+
oppositeDirectionsGreaterThan
|
|
124
|
+
)
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
module.exports = Comparator
|
|
129
|
+
|
|
130
|
+
const parseOptions = require('../internal/parse-options')
|
|
131
|
+
const {re, t} = require('../internal/re')
|
|
132
|
+
const cmp = require('../functions/cmp')
|
|
133
|
+
const debug = require('../internal/debug')
|
|
134
|
+
const SemVer = require('./semver')
|
|
135
|
+
const Range = require('./range')
|