@@ -25,7 +25,7 @@ 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
28
+ You can also just load the module for the function that you care about if
29
29
you' d like to minimize your footprint.
30
30
31
31
```js
@@ -78,8 +78,8 @@ const semverOutside = require('semver/ranges/outside')
78
78
const semverGtr = require(' semver/ranges/gtr' )
79
79
const semverLtr = require(' semver/ranges/ltr' )
80
80
const semverIntersects = require(' semver/ranges/intersects' )
81
- const simplifyRange = require(' semver/ranges/simplify' )
82
- const rangeSubset = require(' semver/ranges/subset' )
81
+ const semverSimplifyRange = require(' semver/ranges/simplify' )
82
+ const semverRangeSubset = require(' semver/ranges/subset' )
83
83
```
84
84
85
85
As a command-line utility:
@@ -144,7 +144,7 @@ A leading `"="` or `"v"` character is stripped off and ignored.
144
144
145
145
## Ranges
146
146
147
- A `version range` is a set of `comparators` which specify versions
147
+ A `version range` is a set of `comparators` that specify versions
148
148
that satisfy the range.
149
149
150
150
A `comparator` is composed of an `operator` and a `version`. The set
@@ -155,7 +155,7 @@ of primitive `operators` is:
155
155
* `>` Greater than
156
156
* `>=` Greater than or equal to
157
157
* `=` Equal. If no operator is specified, then equality is assumed,
158
- so this operator is optional, but MAY be included.
158
+ so this operator is optional but MAY be included.
159
159
160
160
For example, the comparator `>=1.2.7` would match the versions
161
161
`1.2.7`, `1.2.8`, `2.5.3`, and `1.3.9`, but not the versions `1.2.6`
@@ -189,26 +189,26 @@ For example, the range `>1.2.3-alpha.3` would be allowed to match the
189
189
version `1.2.3-alpha.7`, but it would *not* be satisfied by
190
190
`3.4.5-alpha.9`, even though `3.4.5-alpha.9` is technically "greater
191
191
than" `1.2.3-alpha.3` according to the SemVer sort rules. The version
192
- range only accepts prerelease tags on the `1.2.3` version. The
193
- version `3.4.5` *would* satisfy the range, because it does not have a
192
+ range only accepts prerelease tags on the `1.2.3` version.
193
+ Version `3.4.5` *would* satisfy the range because it does not have a
194
194
prerelease flag, and `3.4.5` is greater than `1.2.3-alpha.7`.
195
195
196
- The purpose for this behavior is twofold. First, prerelease versions
196
+ The purpose of this behavior is twofold. First, prerelease versions
197
197
frequently are updated very quickly, and contain many breaking changes
198
198
that are (by the author' s design) not yet fit for public consumption.
199
- Therefore, by default, they are excluded from range matching
199
+ Therefore, by default, they are excluded from range- matching
200
200
semantics.
201
201
202
202
Second, a user who has opted into using a prerelease version has
203
- clearly indicated the intent to use * that specific* set of
203
+ indicated the intent to use * that specific* set of
204
204
alpha/beta/rc versions. By including a prerelease tag in the range,
205
205
the user is indicating that they are aware of the risk. However, it
206
206
is still not appropriate to assume that they have opted into taking a
207
207
similar risk on the * next* set of prerelease versions.
208
208
209
209
Note that this behavior can be suppressed (treating all prerelease
210
- versions as if they were normal versions, for the purpose of range
211
- matching) by setting the ` includePrerelease` flag on the options
210
+ versions as if they were normal versions, for range-matching)
211
+ by setting the ` includePrerelease` flag on the options
212
212
object to any
213
213
[functions](https://github.com/npm/node-semver#functions) that do
214
214
range matching.
@@ -401,12 +401,12 @@ All methods and classes take a final `options` object argument. All
401
401
options in this object are ` false` by default. The options supported
402
402
are:
403
403
404
- - ` loose` Be more forgiving about not-quite-valid semver strings.
404
+ - ` loose` : Be more forgiving about not-quite-valid semver strings.
405
405
(Any resulting output will always be 100% strict compliant, of
406
406
course.) For backwards compatibility reasons, if the ` options`
407
407
argument is a boolean value instead of an object, it is interpreted
408
408
to be the ` loose` param.
409
- - ` includePrerelease` Set to suppress the [default
409
+ - ` includePrerelease` : Set to suppress the [default
410
410
behavior](https://github.com/npm/node-semver#prerelease-tags) of
411
411
excluding prerelease tagged versions from ranges unless they are
412
412
explicitly opted into.
@@ -415,16 +415,20 @@ Strict-mode Comparators and Ranges will be strict about the SemVer
415
415
strings that they parse.
416
416
417
417
* ` valid(v)` : Return the parsed version, or null if it' s not valid.
418
- * `inc(v, release)`: Return the version incremented by the release
419
- type (`major`, `premajor`, `minor`, `preminor`, `patch`,
418
+ * `inc(v, release, options, identifier, identifierBase)`:
419
+ Return the version incremented by the release
420
+ type (`major`, `premajor`, `minor`, `preminor`, `patch`,
420
421
`prepatch`, or `prerelease`), or null if it' s not valid
421
422
* ` premajor` in one call will bump the version up to the next major
422
423
version and down to a prerelease of that major version.
423
424
` preminor` , and ` prepatch` work the same way.
424
- * If called from a non-prerelease version, the ` prerelease` will work the
425
- same as ` prepatch` . It increments the patch version, then makes a
425
+ * If called from a non-prerelease version, ` prerelease` will work the
426
+ same as ` prepatch` . It increments the patch version and then makes a
426
427
prerelease. If the input version is already a prerelease it simply
427
428
increments it.
429
+ * ` identifier` can be used to prefix ` premajor` , ` preminor` ,
430
+ ` prepatch` , or ` prerelease` version increments. ` identifierBase`
431
+ is the base to be used for the ` prerelease` identifier.
428
432
* ` prerelease(v)` : Returns an array of prerelease components, or null
429
433
if none exist. Example: ` prerelease(' 1.2.3-alpha.1' ) -> [' alpha' , 1]`
430
434
* ` major(v)` : Return the major version number.
@@ -442,7 +446,7 @@ strings that they parse.
442
446
* ` lt(v1, v2)` : ` v1 < v2`
443
447
* ` lte(v1, v2)` : ` v1 < = v2`
444
448
* ` eq(v1, v2)` : ` v1 == v2` This is true if they' re logically equivalent,
445
- even if they' re not the exact same string. You already know how to
449
+ even if they' re not the same string. You already know how to
446
450
compare strings.
447
451
* ` neq(v1, v2)` : ` v1 ! = v2` The opposite of ` eq` .
448
452
* ` cmp(v1, comparator, v2)` : Pass in a comparison string, and it' ll call
@@ -451,15 +455,22 @@ strings that they parse.
451
455
invalid comparison string is provided.
452
456
* `compare(v1, v2)`: Return `0` if `v1 == v2`, or `1` if `v1` is greater, or `-1` if
453
457
`v2` is greater. Sorts in ascending order if passed to `Array.sort()`.
454
- * `rcompare(v1, v2)`: The reverse of compare. Sorts an array of versions
458
+ * `rcompare(v1, v2)`: The reverse of ` compare` . Sorts an array of versions
455
459
in descending order when passed to `Array.sort()`.
456
460
* `compareBuild(v1, v2)`: The same as `compare` but considers `build` when two versions
457
461
are equal. Sorts in ascending order if passed to `Array.sort()`.
458
- `v2` is greater. Sorts in ascending order if passed to `Array.sort( )`.
459
- * `diff(v1, v2)`: Returns difference between two versions by the release type
462
+ * `compareLoose(v1, v2)`: Short for ``compare(v1, v2, { loose: true } )`.
463
+ * `diff(v1, v2)`: Returns the difference between two versions by the release type
460
464
(`major`, `premajor`, `minor`, `preminor`, `patch`, `prepatch`, or `prerelease`),
461
465
or null if the versions are the same.
462
466
467
+ ### Sorting
468
+
469
+ * `sort(versions)`: Returns a sorted array of versions based on the `compareBuild`
470
+ function.
471
+ * `rsort(versions)`: The reverse of `sort`. Returns an array of versions based on
472
+ the `compareBuild` function in descending order.
473
+
463
474
### Comparators
464
475
465
476
* `intersects(comparator)`: Return true if the comparators intersect
@@ -473,19 +484,19 @@ strings that they parse.
473
484
that satisfies the range, or ` null` if none of them do.
474
485
* ` minSatisfying(versions, range)` : Return the lowest version in the list
475
486
that satisfies the range, or ` null` if none of them do.
476
- * ` minVersion(range)` : Return the lowest version that can possibly match
487
+ * ` minVersion(range)` : Return the lowest version that can match
477
488
the given range.
478
- * ` gtr(version, range)` : Return ` true` if version is greater than all the
489
+ * ` gtr(version, range)` : Return ` true` if the version is greater than all the
479
490
versions possible in the range.
480
- * ` ltr(version, range)` : Return ` true` if version is less than all the
491
+ * ` ltr(version, range)` : Return ` true` if the version is less than all the
481
492
versions possible in the range.
482
493
* ` outside(version, range, hilo)` : Return true if the version is outside
483
494
the bounds of the range in either the high or low direction. The
484
495
` hilo` argument must be either the string ` ' >' ` or ` ' <' ` . (This is
485
496
the function called by ` gtr` and ` ltr` .)
486
- * ` intersects(range)` : Return true if any of the ranges comparators intersect
497
+ * ` intersects(range)` : Return true if any of the range comparators intersect.
487
498
* ` simplifyRange(versions, range)` : Return a " simplified" range that
488
- matches the same items in ` versions` list as the range specified. Note
499
+ matches the same items in the ` versions` list as the range specified. Note
489
500
that it does * not* guarantee that it would match the same versions in all
490
501
cases, only for the set of versions provided. This is useful when
491
502
generating ranges by joining together multiple versions with ` || `
@@ -498,7 +509,7 @@ strings that they parse.
498
509
Note that, since ranges may be non-contiguous, a version might not be
499
510
greater than a range, less than a range, * or* satisfy a range! For
500
511
example, the range ` 1.2 < 1.2.9 || > 2.0.0` would have a hole from ` 1.2.9`
501
- until ` 2.0.0` , so the version ` 1.2.10` would not be greater than the
512
+ until ` 2.0.0` , so version ` 1.2.10` would not be greater than the
502
513
range (because ` 2.0.1` satisfies, which is higher), nor less than the
503
514
range (since ` 1.2.8` satisfies, which is lower), and it also does not
504
515
satisfy the range.
@@ -511,13 +522,13 @@ range, use the `satisfies(version, range)` function.
511
522
* ` coerce(version, options)` : Coerces a string to semver if possible
512
523
513
524
This aims to provide a very forgiving translation of a non-semver string to
514
- semver. It looks for the first digit in a string, and consumes all
525
+ semver. It looks for the first digit in a string and consumes all
515
526
remaining characters which satisfy at least a partial semver (e.g., ` 1` ,
516
527
` 1.2` , ` 1.2.3` ) up to the max permitted length (256 characters). Longer
517
528
versions are simply truncated (` 4.6.3.9.2-alpha2` becomes ` 4.6.3` ). All
518
529
surrounding text is simply ignored (` v3.4 replaces v3.3.1` becomes
519
530
` 3.4.0` ). Only text which lacks digits will fail coercion (` version one`
520
- is not valid). The maximum length for any semver component considered for
531
+ is not valid). The maximum length for any semver component considered for
521
532
coercion is 16 characters; longer components will be ignored
522
533
(` 10000000000000000.4.7.4` becomes ` 4.7.4` ). The maximum value for any
523
534
semver component is ` Number.MAX_SAFE_INTEGER || (2** 53 - 1)` ; higher value
@@ -593,7 +604,7 @@ eg), and then pull the module name into the documentation for that specific
593
604
thing.
594
605
-->
595
606
596
- You may pull in just the part of this semver utility that you need, if you
607
+ You may pull in just the part of this semver utility that you need if you
597
608
are sensitive to packing and tree-shaking concerns. The main
598
609
`require(' semver' )` export uses getter functions to lazily load the parts
599
610
of the API that are used.
@@ -636,6 +647,8 @@ The following modules are available:
636
647
* `require(' semver/ranges/min-satisfying' )`
637
648
* `require(' semver/ranges/min-version' )`
638
649
* `require(' semver/ranges/outside' )`
650
+ * `require(' semver/ranges/simplify' )`
651
+ * `require(' semver/ranges/subset' )`
639
652
* `require(' semver/ranges/to-comparators' )`
640
653
* `require(' semver/ranges/valid' )`
641
654
0 commit comments