@vltpkg/semver 0.0.0-0.1730239248325 → 0.0.0-0.1730724342581
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/README.md +11 -5
- package/dist/esm/index.d.ts +3 -52
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +2 -51
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/range.d.ts +1 -1
- package/dist/esm/range.d.ts.map +1 -1
- package/dist/esm/range.js.map +1 -1
- package/dist/esm/version.d.ts +51 -2
- package/dist/esm/version.d.ts.map +1 -1
- package/dist/esm/version.js +51 -2
- package/dist/esm/version.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+

|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# @vltpkg/semver
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
A library for parsing, validating & comparing Semantic Versions used by `vlt`.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
**[Usage](#usage)**
|
|
8
|
+
·
|
|
9
|
+
**[Function](#function)**
|
|
10
|
+
·
|
|
11
|
+
**[Differences from node-semver](#differences)**
|
|
8
12
|
|
|
9
13
|
## Usage
|
|
10
14
|
|
|
@@ -117,7 +121,9 @@ Unless otherwise noted, they throw an error on invalid versions.
|
|
|
117
121
|
versions. This is an internal class, and should usually not be
|
|
118
122
|
used directly.
|
|
119
123
|
|
|
120
|
-
## Differences
|
|
124
|
+
## Differences
|
|
125
|
+
|
|
126
|
+
### Differences from `node-semver` (the one used by `npm`)
|
|
121
127
|
|
|
122
128
|
- The API is slightly different. Most notably, `@vltpkg/semver`
|
|
123
129
|
lacks range intersection and other methods that are not needed
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Range } from './range.js';
|
|
2
|
-
import { IncrementType, Version } from './version.js';
|
|
2
|
+
import { type IncrementType, Version } from './version.js';
|
|
3
3
|
export * from './comparator.js';
|
|
4
4
|
export * from './range.js';
|
|
5
5
|
export * from './version.js';
|
|
@@ -31,56 +31,7 @@ export declare const satisfies: (version: Version | string, range: Range | strin
|
|
|
31
31
|
* Increment the specified part of the version, and return the resulting
|
|
32
32
|
* object. If a Version object is provided, it will be modified in-place.
|
|
33
33
|
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* - `'major'` If the version is a `M.0.0-...` version with a prerelease, then
|
|
37
|
-
* simply drop the prerelease. Otherwise, set the minor and patch to 0, and
|
|
38
|
-
* increment the major. So `1.0.0-beta` becomes `1.0.0`, and `1.2.3` becomes
|
|
39
|
-
* `2.0.0`
|
|
40
|
-
*
|
|
41
|
-
* - `'minor'` If the version is a `M.m.0-...` version with a prerelease, then
|
|
42
|
-
* simply drop the prerelease. Otherwise, set the patch to 0, and increment the
|
|
43
|
-
* minor. So `1.2.0-beta` becomes `1.2.0`, and `1.2.3` becomes `1.3.0`.
|
|
44
|
-
*
|
|
45
|
-
* - `'patch'` If the version has a prerelease, then simply drop the
|
|
46
|
-
* prerelease. Otherwise, increment the patch value. So `1.2.3-beta` becomes
|
|
47
|
-
* `1.2.3` and `1.2.3` becomes `1.2.4`.
|
|
48
|
-
*
|
|
49
|
-
* - `'premajor'` Set the patch and minor versions to `0`, increment the major
|
|
50
|
-
* version, and add a prerelease, using the optional identifier.
|
|
51
|
-
*
|
|
52
|
-
* - `'preminor'` Set the patch version to `0`, increment the minor version,
|
|
53
|
-
* and add a prerelease, using the optional identifier.
|
|
54
|
-
*
|
|
55
|
-
* - `'prepatch'` If a prerelease is already present, increment the patch
|
|
56
|
-
* version, otherwise leave it untouched, and add a prerelease, using the
|
|
57
|
-
* optional identifier.
|
|
58
|
-
*
|
|
59
|
-
* - `'prerelease'` If a prerelease version is present, then behave the same as
|
|
60
|
-
* `'prepatch'`. Otherwise, add a prerelease, using the optional identifier.
|
|
61
|
-
*
|
|
62
|
-
* - `'pre'` This is mostly for use by the other prerelease incrementers.
|
|
63
|
-
*
|
|
64
|
-
* - If a prerelease identifier is provided:
|
|
65
|
-
*
|
|
66
|
-
* Update that named portion of the prerelease. For example,
|
|
67
|
-
* `inc('1.2.3-beta.4', 'pre', 'beta')` would result in `1.2.3-beta.5`.
|
|
68
|
-
*
|
|
69
|
-
* If there is no prerelease identifier by that name, then replace the
|
|
70
|
-
* prerelease with `[name]`. So `inc('1.2.3-alpha.4', 'pre', 'beta')`
|
|
71
|
-
* would result in `1.2.3-beta`.
|
|
72
|
-
*
|
|
73
|
-
* If the prerelease identifer is present, but has no numeric value
|
|
74
|
-
* following it, then add `0`. So `inc('1.2.3-beta', 'pre', 'beta')`
|
|
75
|
-
* would result in `1.2.3-beta.0`.
|
|
76
|
-
*
|
|
77
|
-
* - If no prerelease identifier is provided:
|
|
78
|
-
*
|
|
79
|
-
* If there is no current prerelease, then set the prerelease to `0`. So,
|
|
80
|
-
* `inc('1.2.3', 'pre')` becomes `1.2.3-0`.
|
|
81
|
-
*
|
|
82
|
-
* If the last item in the prerelease is numeric, then increment it. So,
|
|
83
|
-
* `inc('1.2.3-beta.3', 'pre')` becomes `1.2.3-beta.4`.
|
|
34
|
+
* See {@link Version.inc} for full description.
|
|
84
35
|
*/
|
|
85
36
|
export declare const inc: (version: Version | string, part: IncrementType, prereleaseIdentifier?: string) => Version;
|
|
86
37
|
/**
|
|
@@ -219,7 +170,7 @@ export declare const gt: (versionA: Version | string, versionB: Version | string
|
|
|
219
170
|
export declare const gte: (versionA: Version | string, versionB: Version | string) => boolean;
|
|
220
171
|
/** true if versionA is < versionB. throws on invalid values */
|
|
221
172
|
export declare const lt: (versionA: Version | string, versionB: Version | string) => boolean;
|
|
222
|
-
/** true if versionA is
|
|
173
|
+
/** true if versionA is <= versionB. throws on invalid values */
|
|
223
174
|
export declare const lte: (versionA: Version | string, versionB: Version | string) => boolean;
|
|
224
175
|
/** true if versionA is not equal to versionB. throws on invalid values */
|
|
225
176
|
export declare const neq: (versionA: Version | string, versionB: Version | string) => boolean;
|
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,KAAK,aAAa,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAG1D,cAAc,iBAAiB,CAAA;AAC/B,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA;AAE5B,kEAAkE;AAClE,eAAO,MAAM,KAAK,YAAa,OAAO,GAAG,MAAM,wBAO9C,CAAA;AAED,iEAAiE;AACjE,eAAO,MAAM,UAAU,UACd,KAAK,GAAG,MAAM,mDAYtB,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,KAAK,YAAa,OAAO,GAAG,MAAM,YAAqB,CAAA;AAEpE;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,UAAW,KAAK,GAAG,MAAM,YAC3B,CAAA;AAErB;;GAEG;AACH,eAAO,MAAM,SAAS,YACX,OAAO,GAAG,MAAM,SAClB,KAAK,GAAG,MAAM,yCActB,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,GAAG,YACL,OAAO,GAAG,MAAM,QACnB,aAAa,yBACI,MAAM,YAKI,CAAA;AAEnC;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,UAAU,MAClB,OAAO,GAAG,MAAM,KAChB,OAAO,GAAG,MAAM,WAUpB,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,IAAI,GAAI,CAAC,SAAS,OAAO,GAAG,MAAM,2BACvC,CAAC,EAAE,KAC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CAAA;AACD;;;GAGG;AACH,eAAO,MAAM,KAAK,YAAa,OAAO,GAAG,MAAM,yBAI9C,CAAA;AAED,sEAAsE;AACtE,eAAO,MAAM,MAAM,GAAI,CAAC,SAAS,OAAO,GAAG,MAAM,+BACrC,CAAC,EAAE,KACZ,CAAC,EAKA,CAAA"}
|
package/dist/esm/index.js
CHANGED
|
@@ -67,56 +67,7 @@ export const satisfies = (version, range, includePrerelease = false) => {
|
|
|
67
67
|
* Increment the specified part of the version, and return the resulting
|
|
68
68
|
* object. If a Version object is provided, it will be modified in-place.
|
|
69
69
|
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
* - `'major'` If the version is a `M.0.0-...` version with a prerelease, then
|
|
73
|
-
* simply drop the prerelease. Otherwise, set the minor and patch to 0, and
|
|
74
|
-
* increment the major. So `1.0.0-beta` becomes `1.0.0`, and `1.2.3` becomes
|
|
75
|
-
* `2.0.0`
|
|
76
|
-
*
|
|
77
|
-
* - `'minor'` If the version is a `M.m.0-...` version with a prerelease, then
|
|
78
|
-
* simply drop the prerelease. Otherwise, set the patch to 0, and increment the
|
|
79
|
-
* minor. So `1.2.0-beta` becomes `1.2.0`, and `1.2.3` becomes `1.3.0`.
|
|
80
|
-
*
|
|
81
|
-
* - `'patch'` If the version has a prerelease, then simply drop the
|
|
82
|
-
* prerelease. Otherwise, increment the patch value. So `1.2.3-beta` becomes
|
|
83
|
-
* `1.2.3` and `1.2.3` becomes `1.2.4`.
|
|
84
|
-
*
|
|
85
|
-
* - `'premajor'` Set the patch and minor versions to `0`, increment the major
|
|
86
|
-
* version, and add a prerelease, using the optional identifier.
|
|
87
|
-
*
|
|
88
|
-
* - `'preminor'` Set the patch version to `0`, increment the minor version,
|
|
89
|
-
* and add a prerelease, using the optional identifier.
|
|
90
|
-
*
|
|
91
|
-
* - `'prepatch'` If a prerelease is already present, increment the patch
|
|
92
|
-
* version, otherwise leave it untouched, and add a prerelease, using the
|
|
93
|
-
* optional identifier.
|
|
94
|
-
*
|
|
95
|
-
* - `'prerelease'` If a prerelease version is present, then behave the same as
|
|
96
|
-
* `'prepatch'`. Otherwise, add a prerelease, using the optional identifier.
|
|
97
|
-
*
|
|
98
|
-
* - `'pre'` This is mostly for use by the other prerelease incrementers.
|
|
99
|
-
*
|
|
100
|
-
* - If a prerelease identifier is provided:
|
|
101
|
-
*
|
|
102
|
-
* Update that named portion of the prerelease. For example,
|
|
103
|
-
* `inc('1.2.3-beta.4', 'pre', 'beta')` would result in `1.2.3-beta.5`.
|
|
104
|
-
*
|
|
105
|
-
* If there is no prerelease identifier by that name, then replace the
|
|
106
|
-
* prerelease with `[name]`. So `inc('1.2.3-alpha.4', 'pre', 'beta')`
|
|
107
|
-
* would result in `1.2.3-beta`.
|
|
108
|
-
*
|
|
109
|
-
* If the prerelease identifer is present, but has no numeric value
|
|
110
|
-
* following it, then add `0`. So `inc('1.2.3-beta', 'pre', 'beta')`
|
|
111
|
-
* would result in `1.2.3-beta.0`.
|
|
112
|
-
*
|
|
113
|
-
* - If no prerelease identifier is provided:
|
|
114
|
-
*
|
|
115
|
-
* If there is no current prerelease, then set the prerelease to `0`. So,
|
|
116
|
-
* `inc('1.2.3', 'pre')` becomes `1.2.3-0`.
|
|
117
|
-
*
|
|
118
|
-
* If the last item in the prerelease is numeric, then increment it. So,
|
|
119
|
-
* `inc('1.2.3-beta.3', 'pre')` becomes `1.2.3-beta.4`.
|
|
70
|
+
* See {@link Version.inc} for full description.
|
|
120
71
|
*/
|
|
121
72
|
export const inc = (version, part, prereleaseIdentifier) => (typeof version === 'string' ?
|
|
122
73
|
Version.parse(version)
|
|
@@ -358,7 +309,7 @@ export const gt = (versionA, versionB) => compare(versionA, versionB) > 0;
|
|
|
358
309
|
export const gte = (versionA, versionB) => compare(versionA, versionB) >= 0;
|
|
359
310
|
/** true if versionA is < versionB. throws on invalid values */
|
|
360
311
|
export const lt = (versionA, versionB) => compare(versionA, versionB) < 0;
|
|
361
|
-
/** true if versionA is
|
|
312
|
+
/** true if versionA is <= versionB. throws on invalid values */
|
|
362
313
|
export const lte = (versionA, versionB) => compare(versionA, versionB) <= 0;
|
|
363
314
|
/** true if versionA is not equal to versionB. throws on invalid values */
|
|
364
315
|
export const neq = (versionA, versionB) => compare(versionA, versionB) !== 0;
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAiB,OAAO,EAAE,MAAM,cAAc,CAAA;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAEjD,cAAc,iBAAiB,CAAA;AAC/B,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA;AAE5B,kEAAkE;AAClE,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,OAAyB,EAAE,EAAE;IACjD,IAAI,OAAO,YAAY,OAAO;QAAE,OAAO,OAAO,CAAA;IAC9C,IAAI,CAAC;QACH,OAAO,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAA;IACvC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAA;IAClB,CAAC;AACH,CAAC,CAAA;AAED,iEAAiE;AACjE,MAAM,CAAC,MAAM,UAAU,GAAG,CACxB,KAAqB,EACrB,iBAAiB,GAAG,KAAK,EACzB,EAAE;IACF,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,IAAI,KAAK,CAAC,iBAAiB,KAAK,iBAAiB;YAAE,OAAO,KAAK,CAAA;QAC/D,KAAK,GAAG,KAAK,CAAC,GAAG,CAAA;IACnB,CAAC;IACD,IAAI,CAAC;QACH,OAAO,IAAI,KAAK,CAAC,KAAK,EAAE,iBAAiB,CAAC,CAAA;IAC5C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAA;IAClB,C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B,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;IAClB,IAAI,CAAC,CAAC;QAAE,OAAO,KAAK,CAAA;IACpB,OAAO,CAAC,CAAC,CAAC,UAAU,EAAE,MAAM,CAAA;AAC9B,CAAC,CAAC,CAAA","sourcesContent":["import { Range } from './range.js'\nimport { IncrementType, Version } from './version.js'\nimport { syntaxError } from '@vltpkg/error-cause'\n\nexport * from './comparator.js'\nexport * from './range.js'\nexport * from './version.js'\n\n/** Return the parsed version string, or `undefined` if invalid */\nexport const parse = (version: Version | string) => {\n if (version instanceof Version) return version\n try {\n return Version.parse(String(version))\n } catch {\n return undefined\n }\n}\n\n/** Return the parsed version range, or `undefined` if invalid */\nexport const parseRange = (\n range: Range | string,\n includePrerelease = false,\n) => {\n if (typeof range === 'object') {\n if (range.includePrerelease === includePrerelease) return range\n range = range.raw\n }\n try {\n return new Range(range, includePrerelease)\n } catch {\n return undefined\n }\n}\n\n/**\n * return true if the version is valid\n *\n * Note: do not use this if you intend to immediately parse the version if it's\n * valid. Just use {@link parse}, and guard the possible undefined value, or\n * use `Version.parse(..)` to throw on invalid values.\n */\nexport const valid = (version: Version | string) => !!parse(version)\n\n/**\n * return true if the range is valid\n *\n * Note: do not use this if you intend to immediately parse the range if it's\n * valid. Just use {@link parseRange}, and guard the possible undefined value,\n * or use `new Range(..)` to throw on invalid values.\n */\nexport const validRange = (range: Range | string) =>\n !!parseRange(range)\n\n/**\n * Return true if the version satisfies the range.\n */\nexport const satisfies = (\n version: Version | string,\n range: Range | string,\n includePrerelease = false,\n) => {\n if (typeof version === 'string') {\n const parsed = parse(version)\n if (!parsed) return false\n version = parsed\n }\n if (typeof range === 'string') {\n const parsed = parseRange(range, includePrerelease)\n if (!parsed) return false\n range = parsed\n }\n return version.satisfies(range)\n}\n\n/**\n * Increment the specified part of the version, and return the resulting\n * object. If a Version object is provided, it will be modified in-place.\n *\n * Part behaviors:\n *\n * - `'major'` If the version is a `M.0.0-...` version with a prerelease, then\n * simply drop the prerelease. Otherwise, set the minor and patch to 0, and\n * increment the major. So `1.0.0-beta` becomes `1.0.0`, and `1.2.3` becomes\n * `2.0.0`\n *\n * - `'minor'` If the version is a `M.m.0-...` version with a prerelease, then\n * simply drop the prerelease. Otherwise, set the patch to 0, and increment the\n * minor. So `1.2.0-beta` becomes `1.2.0`, and `1.2.3` becomes `1.3.0`.\n *\n * - `'patch'` If the version has a prerelease, then simply drop the\n * prerelease. Otherwise, increment the patch value. So `1.2.3-beta` becomes\n * `1.2.3` and `1.2.3` becomes `1.2.4`.\n *\n * - `'premajor'` Set the patch and minor versions to `0`, increment the major\n * version, and add a prerelease, using the optional identifier.\n *\n * - `'preminor'` Set the patch version to `0`, increment the minor version,\n * and add a prerelease, using the optional identifier.\n *\n * - `'prepatch'` If a prerelease is already present, increment the patch\n * version, otherwise leave it untouched, and add a prerelease, using the\n * optional identifier.\n *\n * - `'prerelease'` If a prerelease version is present, then behave the same as\n * `'prepatch'`. Otherwise, add a prerelease, using the optional identifier.\n *\n * - `'pre'` This is mostly for use by the other prerelease incrementers.\n *\n * - If a prerelease identifier is provided:\n *\n * Update that named portion of the prerelease. For example,\n * `inc('1.2.3-beta.4', 'pre', 'beta')` would result in `1.2.3-beta.5`.\n *\n * If there is no prerelease identifier by that name, then replace the\n * prerelease with `[name]`. So `inc('1.2.3-alpha.4', 'pre', 'beta')`\n * would result in `1.2.3-beta`.\n *\n * If the prerelease identifer is present, but has no numeric value\n * following it, then add `0`. So `inc('1.2.3-beta', 'pre', 'beta')`\n * would result in `1.2.3-beta.0`.\n *\n * - If no prerelease identifier is provided:\n *\n * If there is no current prerelease, then set the prerelease to `0`. So,\n * `inc('1.2.3', 'pre')` becomes `1.2.3-0`.\n *\n * If the last item in the prerelease is numeric, then increment it. So,\n * `inc('1.2.3-beta.3', 'pre')` becomes `1.2.3-beta.4`.\n */\nexport const inc = (\n version: Version | string,\n part: IncrementType,\n prereleaseIdentifier?: string,\n) =>\n (typeof version === 'string' ?\n Version.parse(version)\n : version\n ).inc(part, prereleaseIdentifier)\n\n/**\n * The method used by {@link sort}, exported for passing directly to\n * `Array.sort`.\n *\n * Usage:\n *\n * ```ts\n * import { sortMethod } from '@vltpkg/semver'\n * const versions = ['1.2.3', '5.2.3', '2.3.4']\n * console.log(versions.sort(sortMethod))\n * // ['1.2.3', '2.3.4', '5.2.3']\n * ```\n */\nexport const sortMethod = (\n a: Version | string,\n b: Version | string,\n) => {\n const pa = parse(a)\n const pb = parse(b)\n /* c8 ignore start - nondeterministic */\n if (!pa && !pb) return String(a).localeCompare(String(b), 'en')\n if (!pa) return 1\n if (!pb) return -1\n /* c8 ignore stop */\n return pa.compare(pb)\n}\n\n/**\n * Sort an array of version strings or objects in ascending SemVer precedence\n * order (ie, lowest versions first).\n *\n * Invalid version strings are sorted to the end of the array in ascending\n * alphabetical order.\n *\n * Note: when using this method, the list is cloned prior to sorting, to\n * prevent surprising mutation. To sort the list in place, see\n * {@link sortMethod}.\n */\nexport const sort = <T extends Version | string = Version | string>(\n list: T[],\n): T[] => list.slice().sort(sortMethod)\n\n/**\n * Sort an array of version strings or objects in descending SemVer\n * precedence order (ie, highest versions first).\n *\n * Invalid version strings are sorted to the end of the array in ascending\n * alphabetical order.\n *\n * Note: when using this method, the list is cloned prior to sorting, to\n * prevent surprising mutation. To sort the list in place, see\n * {@link rsortMethod}.\n */\nexport const rsort = <T extends Version | string = Version | string>(\n list: T[],\n): T[] => list.slice().sort(rsortMethod)\n\n/**\n * The method used by {@link rsort}, exported for passing directly to\n * `Array.sort`.\n *\n * Usage:\n *\n * ```ts\n * import { rsortMethod } from '@vltpkg/semver'\n * const versions = ['1.2.3', '5.2.3', '2.3.4']\n * console.log(versions.sort(rsortMethod))\n * // ['5.2.3', '2.3.4', '1.2.3']\n * ```\n */\nexport const rsortMethod = (\n a: Version | string,\n b: Version | string,\n) => {\n const pa = parse(a)\n const pb = parse(b)\n /* c8 ignore start - nondeterministic */\n if (!pa && !pb) return String(a).localeCompare(String(b), 'en')\n if (!pa) return 1\n if (!pb) return -1\n /* c8 ignore stop */\n return pa.rcompare(pb)\n}\n\n/**\n * Method used by {@link filter}, for use in `Array.filter` directly.\n *\n * Usage:\n *\n * ```ts\n * import { filterMethod } from '@vltpkg/semver'\n * const versions = ['1.2.3', '5.2.3', '2.3.4']\n * console.log(versions.filter(filterMethod('>=2.x')))\n * // ['5.2.3', '2.3.4']\n * ```\n */\nexport const filterMethod = (\n range: Range | string,\n includePrerelease = false,\n): ((version: Version | string) => boolean) => {\n const r = parseRange(range, includePrerelease)\n return !r ?\n () => false\n : version => satisfies(version, r, r.includePrerelease)\n}\n\n/**\n * Filter a list of versions to find all that match a given range.\n */\nexport const filter = <T extends Version | string = Version | string>(\n list: T[],\n range: Range | string,\n includePrerelease = false,\n): T[] => list.filter(filterMethod(range, includePrerelease))\n\n/**\n * Find the highest-precedence match for a range within a list of versions\n *\n * Returns `undefined` if no match was found.\n */\nexport const highest = (\n list: (Version | string)[],\n range: Range | string,\n includePrerelease = false,\n): Version | undefined => {\n const r = parseRange(range, includePrerelease)\n if (!r) return undefined\n let max: Version | undefined = undefined\n for (const v of list) {\n const version = parse(v)\n if (!version) continue\n if (!version.satisfies(r)) continue\n if (!max) max = version\n else if (version.greaterThan(max)) max = version\n }\n return max\n}\n\n/**\n * Faster form of {@link highest}, for use when the list is sorted\n * in precedence order (lower-precedence versions first).\n *\n * Note: This stops at the first match, and will produce incorrect results\n * when the list is not properly sorted!\n */\nexport const sortedHighest = (\n list: (Version | string)[],\n range: Range | string,\n includePrerelease = false,\n): Version | undefined => {\n const r = parseRange(range, includePrerelease)\n if (!r) return undefined\n for (let i = list.length - 1; i >= 0; i--) {\n const v = list[i]\n /* c8 ignore next */\n if (!v) continue\n const version = parse(v)\n if (!version) continue\n if (!version.satisfies(r)) continue\n return version\n }\n}\n\n/**\n * Faster form of {@link highest}, for use when the list is sorted\n * in reverse precedence order (higher-precedence versions first).\n *\n * Note: This stops at the first match, and will produce incorrect results\n * when the list is not properly sorted!\n */\nexport const rsortedHighest = (\n list: (Version | string)[],\n range: Range | string,\n includePrerelease = false,\n): Version | undefined => {\n const r = parseRange(range, includePrerelease)\n if (!r) return undefined\n for (const v of list) {\n const version = parse(v)\n if (!version) continue\n if (!version.satisfies(r)) continue\n return version\n }\n}\n\n/**\n * Find the lowest-precedence match for a range within a list of versions\n *\n * Returns `undefined` if no match was found.\n */\nexport const lowest = (\n list: (Version | string)[],\n range: Range | string,\n includePrerelease = false,\n): Version | undefined => {\n const r = parseRange(range, includePrerelease)\n if (!r) return undefined\n let min: Version | undefined = undefined\n for (const v of list) {\n const version = parse(v)\n if (!version) continue\n if (!version.satisfies(r)) continue\n if (!min) min = version\n else if (version.lessThan(min)) min = version\n }\n return min\n}\n\n/**\n * Faster form of {@link lowest}, for use when the list is sorted\n * in precedence order (lower-precedence versions first).\n *\n * Note: This stops at the first match, and will produce incorrect results\n * when the list is not properly sorted!\n */\nexport const sortedLowest = (\n list: (Version | string)[],\n range: Range | string,\n includePrerelease = false,\n): Version | undefined =>\n rsortedHighest(list, range, includePrerelease)\n\n/**\n * Faster form of {@link lowest}, for use when the list is sorted\n * in reverse precedence order (higher-precedence versions first).\n *\n * Note: This stops at the first match, and will produce incorrect results\n * when the list is not properly sorted!\n */\nexport const rsortedLowest = (\n list: (Version | string)[],\n range: Range | string,\n includePrerelease = false,\n): Version | undefined =>\n sortedHighest(list, range, includePrerelease)\n\n/**\n * Same as {@link sortMethod}, but throws if either version is not valid.\n * 1 if versionA is higher precedence than versionB\n * -1 if versionA is lower precedence than versionB\n * 0 if they have equal precedence\n */\nexport const compare = (\n versionA: Version | string,\n versionB: Version | string,\n) => {\n const a = parse(versionA)\n if (!a) {\n throw syntaxError('invalid version', { found: versionA })\n }\n const b = parse(versionB)\n if (!b) {\n throw syntaxError('invalid version', { found: versionB })\n }\n return a.compare(b)\n}\n\n/**\n * Inverse of {@link compare}\n *\n * Same as {@link rsortMethod}, but throws if either version is not valid.\n *\n * -1 if versionA is higher precedence than versionB\n * 1 if versionA is lower precedence than versionB\n * 0 if they have equal precedence\n */\nexport const rcompare = (\n versionA: Version | string,\n versionB: Version | string,\n) => compare(versionB, versionA)\n\n/** true if versionA is > versionB. throws on invalid values */\nexport const gt = (\n versionA: Version | string,\n versionB: Version | string,\n) => compare(versionA, versionB) > 0\n/** true if versionA is >= versionB. throws on invalid values */\nexport const gte = (\n versionA: Version | string,\n versionB: Version | string,\n) => compare(versionA, versionB) >= 0\n/** true if versionA is < versionB. throws on invalid values */\nexport const lt = (\n versionA: Version | string,\n versionB: Version | string,\n) => compare(versionA, versionB) < 0\n/** true if versionA is <= versionB. throws on invalid values */\nexport const lte = (\n versionA: Version | string,\n versionB: Version | string,\n) => compare(versionA, versionB) <= 0\n/** true if versionA is not equal to versionB. throws on invalid values */\nexport const neq = (\n versionA: Version | string,\n versionB: Version | string,\n) => compare(versionA, versionB) !== 0\n/** true if versionA is equal to versionB. throws on invalid values */\nexport const eq = (\n versionA: Version | string,\n versionB: Version | string,\n) => compare(versionA, versionB) === 0\n\n/** extract the major version number, or undefined if invalid */\nexport const major = (version: Version | string) =>\n parse(version)?.major\n/** extract the minor version number, or undefined if invalid */\nexport const minor = (version: Version | string) =>\n parse(version)?.minor\n/** extract the patch version number, or undefined if invalid */\nexport const patch = (version: Version | string) =>\n parse(version)?.patch\n/**\n * extract the list of prerelease identifiers, or undefined if the version\n * is invalid. If no prerelease identifiers are present, returns `[]`.\n */\nexport const prerelease = (version: Version | string) => {\n const p = parse(version)\n if (!p) return undefined\n return p.prerelease ?? []\n}\n/**\n * extract the list of build identifiers, or undefined if the version\n * is invalid. If no build identifiers are present, returns `[]`.\n */\nexport const build = (version: Version | string) => {\n const p = parse(version)\n if (!p) return undefined\n return p.build ?? []\n}\n\n/** return all versions that do not have any prerelease identifiers */\nexport const stable = <T extends Version | string = Version | string>(\n versions: T[],\n): T[] =>\n versions.filter(v => {\n const p = parse(v)\n if (!p) return false\n return !p.prerelease?.length\n })\n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MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,OAAyB,EAAE,EAAE,CACjD,KAAK,CAAC,OAAO,CAAC,EAAE,KAAK,CAAA;AACvB,gEAAgE;AAChE,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,OAAyB,EAAE,EAAE,CACjD,KAAK,CAAC,OAAO,CAAC,EAAE,KAAK,CAAA;AACvB,gEAAgE;AAChE,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,OAAyB,EAAE,EAAE,CACjD,KAAK,CAAC,OAAO,CAAC,EAAE,KAAK,CAAA;AACvB;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,OAAyB,EAAE,EAAE;IACtD,MAAM,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,CAAA;IACxB,IAAI,CAAC,CAAC;QAAE,OAAO,SAAS,CAAA;IACxB,OAAO,CAAC,CAAC,UAAU,IAAI,EAAE,CAAA;AAC3B,CAAC,CAAA;AACD;;;GAGG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,OAAyB,EAAE,EAAE;IACjD,MAAM,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,CAAA;IACxB,IAAI,CAAC,CAAC;QAAE,OAAO,SAAS,CAAA;IACxB,OAAO,CAAC,CAAC,KAAK,IAAI,EAAE,CAAA;AACtB,CAAC,CAAA;AAED,sEAAsE;AACtE,MAAM,CAAC,MAAM,MAAM,GAAG,CACpB,QAAa,EACR,EAAE,CACP,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE;IAClB,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;IAClB,IAAI,CAAC,CAAC;QAAE,OAAO,KAAK,CAAA;IACpB,OAAO,CAAC,CAAC,CAAC,UAAU,EAAE,MAAM,CAAA;AAC9B,CAAC,CAAC,CAAA","sourcesContent":["import { Range } from './range.js'\nimport { type IncrementType, Version } from './version.js'\nimport { syntaxError } from '@vltpkg/error-cause'\n\nexport * from './comparator.js'\nexport * from './range.js'\nexport * from './version.js'\n\n/** Return the parsed version string, or `undefined` if invalid */\nexport const parse = (version: Version | string) => {\n if (version instanceof Version) return version\n try {\n return Version.parse(String(version))\n } catch {\n return undefined\n }\n}\n\n/** Return the parsed version range, or `undefined` if invalid */\nexport const parseRange = (\n range: Range | string,\n includePrerelease = false,\n) => {\n if (typeof range === 'object') {\n if (range.includePrerelease === includePrerelease) return range\n range = range.raw\n }\n try {\n return new Range(range, includePrerelease)\n } catch {\n return undefined\n }\n}\n\n/**\n * return true if the version is valid\n *\n * Note: do not use this if you intend to immediately parse the version if it's\n * valid. Just use {@link parse}, and guard the possible undefined value, or\n * use `Version.parse(..)` to throw on invalid values.\n */\nexport const valid = (version: Version | string) => !!parse(version)\n\n/**\n * return true if the range is valid\n *\n * Note: do not use this if you intend to immediately parse the range if it's\n * valid. Just use {@link parseRange}, and guard the possible undefined value,\n * or use `new Range(..)` to throw on invalid values.\n */\nexport const validRange = (range: Range | string) =>\n !!parseRange(range)\n\n/**\n * Return true if the version satisfies the range.\n */\nexport const satisfies = (\n version: Version | string,\n range: Range | string,\n includePrerelease = false,\n) => {\n if (typeof version === 'string') {\n const parsed = parse(version)\n if (!parsed) return false\n version = parsed\n }\n if (typeof range === 'string') {\n const parsed = parseRange(range, includePrerelease)\n if (!parsed) return false\n range = parsed\n }\n return version.satisfies(range)\n}\n\n/**\n * Increment the specified part of the version, and return the resulting\n * object. If a Version object is provided, it will be modified in-place.\n *\n * See {@link Version.inc} for full description.\n */\nexport const inc = (\n version: Version | string,\n part: IncrementType,\n prereleaseIdentifier?: string,\n) =>\n (typeof version === 'string' ?\n Version.parse(version)\n : version\n ).inc(part, prereleaseIdentifier)\n\n/**\n * The method used by {@link sort}, exported for passing directly to\n * `Array.sort`.\n *\n * Usage:\n *\n * ```ts\n * import { sortMethod } from '@vltpkg/semver'\n * const versions = ['1.2.3', '5.2.3', '2.3.4']\n * console.log(versions.sort(sortMethod))\n * // ['1.2.3', '2.3.4', '5.2.3']\n * ```\n */\nexport const sortMethod = (\n a: Version | string,\n b: Version | string,\n) => {\n const pa = parse(a)\n const pb = parse(b)\n /* c8 ignore start - nondeterministic */\n if (!pa && !pb) return String(a).localeCompare(String(b), 'en')\n if (!pa) return 1\n if (!pb) return -1\n /* c8 ignore stop */\n return pa.compare(pb)\n}\n\n/**\n * Sort an array of version strings or objects in ascending SemVer precedence\n * order (ie, lowest versions first).\n *\n * Invalid version strings are sorted to the end of the array in ascending\n * alphabetical order.\n *\n * Note: when using this method, the list is cloned prior to sorting, to\n * prevent surprising mutation. To sort the list in place, see\n * {@link sortMethod}.\n */\nexport const sort = <T extends Version | string = Version | string>(\n list: T[],\n): T[] => list.slice().sort(sortMethod)\n\n/**\n * Sort an array of version strings or objects in descending SemVer\n * precedence order (ie, highest versions first).\n *\n * Invalid version strings are sorted to the end of the array in ascending\n * alphabetical order.\n *\n * Note: when using this method, the list is cloned prior to sorting, to\n * prevent surprising mutation. To sort the list in place, see\n * {@link rsortMethod}.\n */\nexport const rsort = <T extends Version | string = Version | string>(\n list: T[],\n): T[] => list.slice().sort(rsortMethod)\n\n/**\n * The method used by {@link rsort}, exported for passing directly to\n * `Array.sort`.\n *\n * Usage:\n *\n * ```ts\n * import { rsortMethod } from '@vltpkg/semver'\n * const versions = ['1.2.3', '5.2.3', '2.3.4']\n * console.log(versions.sort(rsortMethod))\n * // ['5.2.3', '2.3.4', '1.2.3']\n * ```\n */\nexport const rsortMethod = (\n a: Version | string,\n b: Version | string,\n) => {\n const pa = parse(a)\n const pb = parse(b)\n /* c8 ignore start - nondeterministic */\n if (!pa && !pb) return String(a).localeCompare(String(b), 'en')\n if (!pa) return 1\n if (!pb) return -1\n /* c8 ignore stop */\n return pa.rcompare(pb)\n}\n\n/**\n * Method used by {@link filter}, for use in `Array.filter` directly.\n *\n * Usage:\n *\n * ```ts\n * import { filterMethod } from '@vltpkg/semver'\n * const versions = ['1.2.3', '5.2.3', '2.3.4']\n * console.log(versions.filter(filterMethod('>=2.x')))\n * // ['5.2.3', '2.3.4']\n * ```\n */\nexport const filterMethod = (\n range: Range | string,\n includePrerelease = false,\n): ((version: Version | string) => boolean) => {\n const r = parseRange(range, includePrerelease)\n return !r ?\n () => false\n : version => satisfies(version, r, r.includePrerelease)\n}\n\n/**\n * Filter a list of versions to find all that match a given range.\n */\nexport const filter = <T extends Version | string = Version | string>(\n list: T[],\n range: Range | string,\n includePrerelease = false,\n): T[] => list.filter(filterMethod(range, includePrerelease))\n\n/**\n * Find the highest-precedence match for a range within a list of versions\n *\n * Returns `undefined` if no match was found.\n */\nexport const highest = (\n list: (Version | string)[],\n range: Range | string,\n includePrerelease = false,\n): Version | undefined => {\n const r = parseRange(range, includePrerelease)\n if (!r) return undefined\n let max: Version | undefined = undefined\n for (const v of list) {\n const version = parse(v)\n if (!version) continue\n if (!version.satisfies(r)) continue\n if (!max) max = version\n else if (version.greaterThan(max)) max = version\n }\n return max\n}\n\n/**\n * Faster form of {@link highest}, for use when the list is sorted\n * in precedence order (lower-precedence versions first).\n *\n * Note: This stops at the first match, and will produce incorrect results\n * when the list is not properly sorted!\n */\nexport const sortedHighest = (\n list: (Version | string)[],\n range: Range | string,\n includePrerelease = false,\n): Version | undefined => {\n const r = parseRange(range, includePrerelease)\n if (!r) return undefined\n for (let i = list.length - 1; i >= 0; i--) {\n const v = list[i]\n /* c8 ignore next */\n if (!v) continue\n const version = parse(v)\n if (!version) continue\n if (!version.satisfies(r)) continue\n return version\n }\n}\n\n/**\n * Faster form of {@link highest}, for use when the list is sorted\n * in reverse precedence order (higher-precedence versions first).\n *\n * Note: This stops at the first match, and will produce incorrect results\n * when the list is not properly sorted!\n */\nexport const rsortedHighest = (\n list: (Version | string)[],\n range: Range | string,\n includePrerelease = false,\n): Version | undefined => {\n const r = parseRange(range, includePrerelease)\n if (!r) return undefined\n for (const v of list) {\n const version = parse(v)\n if (!version) continue\n if (!version.satisfies(r)) continue\n return version\n }\n}\n\n/**\n * Find the lowest-precedence match for a range within a list of versions\n *\n * Returns `undefined` if no match was found.\n */\nexport const lowest = (\n list: (Version | string)[],\n range: Range | string,\n includePrerelease = false,\n): Version | undefined => {\n const r = parseRange(range, includePrerelease)\n if (!r) return undefined\n let min: Version | undefined = undefined\n for (const v of list) {\n const version = parse(v)\n if (!version) continue\n if (!version.satisfies(r)) continue\n if (!min) min = version\n else if (version.lessThan(min)) min = version\n }\n return min\n}\n\n/**\n * Faster form of {@link lowest}, for use when the list is sorted\n * in precedence order (lower-precedence versions first).\n *\n * Note: This stops at the first match, and will produce incorrect results\n * when the list is not properly sorted!\n */\nexport const sortedLowest = (\n list: (Version | string)[],\n range: Range | string,\n includePrerelease = false,\n): Version | undefined =>\n rsortedHighest(list, range, includePrerelease)\n\n/**\n * Faster form of {@link lowest}, for use when the list is sorted\n * in reverse precedence order (higher-precedence versions first).\n *\n * Note: This stops at the first match, and will produce incorrect results\n * when the list is not properly sorted!\n */\nexport const rsortedLowest = (\n list: (Version | string)[],\n range: Range | string,\n includePrerelease = false,\n): Version | undefined =>\n sortedHighest(list, range, includePrerelease)\n\n/**\n * Same as {@link sortMethod}, but throws if either version is not valid.\n * 1 if versionA is higher precedence than versionB\n * -1 if versionA is lower precedence than versionB\n * 0 if they have equal precedence\n */\nexport const compare = (\n versionA: Version | string,\n versionB: Version | string,\n) => {\n const a = parse(versionA)\n if (!a) {\n throw syntaxError('invalid version', { found: versionA })\n }\n const b = parse(versionB)\n if (!b) {\n throw syntaxError('invalid version', { found: versionB })\n }\n return a.compare(b)\n}\n\n/**\n * Inverse of {@link compare}\n *\n * Same as {@link rsortMethod}, but throws if either version is not valid.\n *\n * -1 if versionA is higher precedence than versionB\n * 1 if versionA is lower precedence than versionB\n * 0 if they have equal precedence\n */\nexport const rcompare = (\n versionA: Version | string,\n versionB: Version | string,\n) => compare(versionB, versionA)\n\n/** true if versionA is > versionB. throws on invalid values */\nexport const gt = (\n versionA: Version | string,\n versionB: Version | string,\n) => compare(versionA, versionB) > 0\n/** true if versionA is >= versionB. throws on invalid values */\nexport const gte = (\n versionA: Version | string,\n versionB: Version | string,\n) => compare(versionA, versionB) >= 0\n/** true if versionA is < versionB. throws on invalid values */\nexport const lt = (\n versionA: Version | string,\n versionB: Version | string,\n) => compare(versionA, versionB) < 0\n/** true if versionA is <= versionB. throws on invalid values */\nexport const lte = (\n versionA: Version | string,\n versionB: Version | string,\n) => compare(versionA, versionB) <= 0\n/** true if versionA is not equal to versionB. throws on invalid values */\nexport const neq = (\n versionA: Version | string,\n versionB: Version | string,\n) => compare(versionA, versionB) !== 0\n/** true if versionA is equal to versionB. throws on invalid values */\nexport const eq = (\n versionA: Version | string,\n versionB: Version | string,\n) => compare(versionA, versionB) === 0\n\n/** extract the major version number, or undefined if invalid */\nexport const major = (version: Version | string) =>\n parse(version)?.major\n/** extract the minor version number, or undefined if invalid */\nexport const minor = (version: Version | string) =>\n parse(version)?.minor\n/** extract the patch version number, or undefined if invalid */\nexport const patch = (version: Version | string) =>\n parse(version)?.patch\n/**\n * extract the list of prerelease identifiers, or undefined if the version\n * is invalid. If no prerelease identifiers are present, returns `[]`.\n */\nexport const prerelease = (version: Version | string) => {\n const p = parse(version)\n if (!p) return undefined\n return p.prerelease ?? []\n}\n/**\n * extract the list of build identifiers, or undefined if the version\n * is invalid. If no build identifiers are present, returns `[]`.\n */\nexport const build = (version: Version | string) => {\n const p = parse(version)\n if (!p) return undefined\n return p.build ?? []\n}\n\n/** return all versions that do not have any prerelease identifiers */\nexport const stable = <T extends Version | string = Version | string>(\n versions: T[],\n): T[] =>\n versions.filter(v => {\n const p = parse(v)\n if (!p) return false\n return !p.prerelease?.length\n })\n"]}
|
package/dist/esm/range.d.ts
CHANGED
package/dist/esm/range.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"range.d.ts","sourceRoot":"","sources":["../../src/range.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"range.d.ts","sourceRoot":"","sources":["../../src/range.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,cAAc,CAAA;AAE3C;;;;;GAKG;AACH,qBAAa,KAAK;;IAChB,2CAA2C;IAC3C,GAAG,EAAE,MAAM,CAAA;IAEX,+BAA+B;IAC/B,KAAK,EAAE,OAAO,CAAA;IAEd,mDAAmD;IACnD,QAAQ,EAAE,OAAO,CAAA;IAEjB,8CAA8C;IAE9C;;;;OAIG;IACH,GAAG,EAAE,UAAU,EAAE,CAAK;IAEtB,yDAAyD;IACzD,iBAAiB,EAAE,OAAO,CAAA;gBAKd,KAAK,EAAE,MAAM,EAAE,iBAAiB,UAAQ;IA4BpD;;OAEG;IACH,IAAI,CAAC,CAAC,EAAE,OAAO;IAIf,yDAAyD;IACzD,QAAQ;CAST"}
|
package/dist/esm/range.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"range.js","sourceRoot":"","sources":["../../src/range.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAG5C;;;;;GAKG;AACH,MAAM,OAAO,KAAK;IAChB,2CAA2C;IAC3C,GAAG,CAAQ;IAEX,+BAA+B;IAC/B,KAAK,CAAS;IAEd,mDAAmD;IACnD,QAAQ,CAAS;IAEjB,8CAA8C;IAE9C;;;;OAIG;IACH,GAAG,GAAiB,EAAE,CAAA;IAEtB,yDAAyD;IACzD,iBAAiB,CAAS;IAE1B,sBAAsB;IACtB,SAAS,CAAS;IAElB,YAAY,KAAa,EAAE,iBAAiB,GAAG,KAAK;QAClD,IAAI,CAAC,GAAG,GAAG,KAAK,CAAA;QAChB,IAAI,CAAC,iBA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ACN,IAAI,IAAI,CAAC,SAAS;YAAE,OAAO,IAAI,CAAC,SAAS,CAAA;QACzC,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;YACpC,OAAO,IAAI,CAAC,SAAS,CAAA;QACvB,CAAC;QACD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QAC1D,OAAO,IAAI,CAAC,SAAS,CAAA;IACvB,CAAC;CACF","sourcesContent":["import { fastSplit } from '@vltpkg/fast-split'\nimport { Comparator } from './comparator.js'\nimport { Version } from './version.js'\n\n/**\n * A representation of a semver range, used to test versions.\n *\n * Includes a set of comparators representing the `||`-separated\n * sections of the range string\n */\nexport class Range {\n /** raw string used to create this Range */\n raw: string\n\n /** true if the range is `*` */\n isAny: boolean\n\n /** true if the range is a single semver version */\n isSingle: boolean\n\n /** true if the range cannot match anything */\n\n /**\n * set of {@link Comparator} objects representing the `||`-separated sections\n * of the range. If at least one of these matches, then the version is a\n * match.\n */\n set: Comparator[] = []\n\n /** true if all prerelease versions should be included */\n includePrerelease: boolean\n\n /** cached toString */\n #toString?: string\n\n constructor(range: string, includePrerelease = false) {\n this.raw = range\n this.includePrerelease = includePrerelease\n this.isAny = false\n let isFirst = true\n this.isSingle = false\n fastSplit(range, '||', -1, part => {\n if (this.isAny) return\n const cmp = new Comparator(part, this.includePrerelease)\n if (cmp.isAny) {\n this.set = [cmp]\n this.isAny = true\n return\n }\n this.set.push(cmp)\n if (!isFirst) this.isSingle = false\n else if (\n Array.isArray(cmp.tuples) &&\n cmp.tuples.length === 1 &&\n Array.isArray(cmp.tuples[0]) &&\n cmp.tuples[0][0] === ''\n ) {\n this.isSingle = true\n }\n isFirst = false\n })\n }\n\n /**\n * test a {@link Version} against the range\n */\n test(v: Version) {\n return this.set.some(c => c.test(v))\n }\n\n /** return the simplified canonical form of this range */\n toString() {\n if (this.#toString) return this.#toString\n if (this.isSingle) {\n this.#toString = String(this.set[0])\n return this.#toString\n }\n this.#toString = this.set.map(c => String(c)).join(' || ')\n return this.#toString\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"range.js","sourceRoot":"","sources":["../../src/range.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAG5C;;;;;GAKG;AACH,MAAM,OAAO,KAAK;IAChB,2CAA2C;IAC3C,GAAG,CAAQ;IAEX,+BAA+B;IAC/B,KAAK,CAAS;IAEd,mDAAmD;IACnD,QAAQ,CAAS;IAEjB,8CAA8C;IAE9C;;;;OAIG;IACH,GAAG,GAAiB,EAAE,CAAA;IAEtB,yDAAyD;IACzD,iBAAiB,CAAS;IAE1B,sBAAsB;IACtB,SAAS,CAAS;IAElB,YAAY,KAAa,EAAE,iBAAiB,GAAG,KAAK;QAClD,IAAI,CAAC,GAAG,GAAG,KAAK,CAAA;QAChB,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAA;QAC1C,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,OAAO,GAAG,IAAI,CAAA;QAClB,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAA;QACrB,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE;YAChC,IAAI,IAAI,CAAC,KAAK;gBAAE,OAAM;YACtB,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAA;YACxD,IAAI,GAAG,CAAC,KAAK,EAAE,CAAC;gBACd,IAAI,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAA;g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","sourcesContent":["import { fastSplit } from '@vltpkg/fast-split'\nimport { Comparator } from './comparator.js'\nimport { type Version } from './version.js'\n\n/**\n * A representation of a semver range, used to test versions.\n *\n * Includes a set of comparators representing the `||`-separated\n * sections of the range string\n */\nexport class Range {\n /** raw string used to create this Range */\n raw: string\n\n /** true if the range is `*` */\n isAny: boolean\n\n /** true if the range is a single semver version */\n isSingle: boolean\n\n /** true if the range cannot match anything */\n\n /**\n * set of {@link Comparator} objects representing the `||`-separated sections\n * of the range. If at least one of these matches, then the version is a\n * match.\n */\n set: Comparator[] = []\n\n /** true if all prerelease versions should be included */\n includePrerelease: boolean\n\n /** cached toString */\n #toString?: string\n\n constructor(range: string, includePrerelease = false) {\n this.raw = range\n this.includePrerelease = includePrerelease\n this.isAny = false\n let isFirst = true\n this.isSingle = false\n fastSplit(range, '||', -1, part => {\n if (this.isAny) return\n const cmp = new Comparator(part, this.includePrerelease)\n if (cmp.isAny) {\n this.set = [cmp]\n this.isAny = true\n return\n }\n this.set.push(cmp)\n if (!isFirst) this.isSingle = false\n else if (\n Array.isArray(cmp.tuples) &&\n cmp.tuples.length === 1 &&\n Array.isArray(cmp.tuples[0]) &&\n cmp.tuples[0][0] === ''\n ) {\n this.isSingle = true\n }\n isFirst = false\n })\n }\n\n /**\n * test a {@link Version} against the range\n */\n test(v: Version) {\n return this.set.some(c => c.test(v))\n }\n\n /** return the simplified canonical form of this range */\n toString() {\n if (this.#toString) return this.#toString\n if (this.isSingle) {\n this.#toString = String(this.set[0])\n return this.#toString\n }\n this.#toString = this.set.map(c => String(c)).join(' || ')\n return this.#toString\n }\n}\n"]}
|
package/dist/esm/version.d.ts
CHANGED
|
@@ -61,7 +61,7 @@ export declare class Version {
|
|
|
61
61
|
greaterThanEqual(v: Version): boolean;
|
|
62
62
|
/** true if this version is < the argument */
|
|
63
63
|
lessThan(v: Version): boolean;
|
|
64
|
-
/** true if this version is
|
|
64
|
+
/** true if this version is <= the argument */
|
|
65
65
|
lessThanEqual(v: Version): boolean;
|
|
66
66
|
/** true if these two versions have equal SemVer precedence */
|
|
67
67
|
equals(v: Version): boolean;
|
|
@@ -72,7 +72,56 @@ export declare class Version {
|
|
|
72
72
|
/**
|
|
73
73
|
* Increment the version in place, in the manner specified.
|
|
74
74
|
*
|
|
75
|
-
*
|
|
75
|
+
* Part behaviors:
|
|
76
|
+
*
|
|
77
|
+
* - `'major'` If the version is a `M.0.0-...` version with a prerelease, then
|
|
78
|
+
* simply drop the prerelease. Otherwise, set the minor and patch to 0, and
|
|
79
|
+
* increment the major. So `1.0.0-beta` becomes `1.0.0`, and `1.2.3` becomes
|
|
80
|
+
* `2.0.0`
|
|
81
|
+
*
|
|
82
|
+
* - `'minor'` If the version is a `M.m.0-...` version with a prerelease, then
|
|
83
|
+
* simply drop the prerelease. Otherwise, set the patch to 0, and increment the
|
|
84
|
+
* minor. So `1.2.0-beta` becomes `1.2.0`, and `1.2.3` becomes `1.3.0`.
|
|
85
|
+
*
|
|
86
|
+
* - `'patch'` If the version has a prerelease, then simply drop the
|
|
87
|
+
* prerelease. Otherwise, increment the patch value. So `1.2.3-beta` becomes
|
|
88
|
+
* `1.2.3` and `1.2.3` becomes `1.2.4`.
|
|
89
|
+
*
|
|
90
|
+
* - `'premajor'` Set the patch and minor versions to `0`, increment the major
|
|
91
|
+
* version, and add a prerelease, using the optional identifier.
|
|
92
|
+
*
|
|
93
|
+
* - `'preminor'` Set the patch version to `0`, increment the minor version,
|
|
94
|
+
* and add a prerelease, using the optional identifier.
|
|
95
|
+
*
|
|
96
|
+
* - `'prepatch'` If a prerelease is already present, increment the patch
|
|
97
|
+
* version, otherwise leave it untouched, and add a prerelease, using the
|
|
98
|
+
* optional identifier.
|
|
99
|
+
*
|
|
100
|
+
* - `'prerelease'` If a prerelease version is present, then behave the same as
|
|
101
|
+
* `'prepatch'`. Otherwise, add a prerelease, using the optional identifier.
|
|
102
|
+
*
|
|
103
|
+
* - `'pre'` This is mostly for use by the other prerelease incrementers.
|
|
104
|
+
*
|
|
105
|
+
* - If a prerelease identifier is provided:
|
|
106
|
+
*
|
|
107
|
+
* Update that named portion of the prerelease. For example,
|
|
108
|
+
* `inc('1.2.3-beta.4', 'pre', 'beta')` would result in `1.2.3-beta.5`.
|
|
109
|
+
*
|
|
110
|
+
* If there is no prerelease identifier by that name, then replace the
|
|
111
|
+
* prerelease with `[name]`. So `inc('1.2.3-alpha.4', 'pre', 'beta')`
|
|
112
|
+
* would result in `1.2.3-beta`.
|
|
113
|
+
*
|
|
114
|
+
* If the prerelease identifer is present, but has no numeric value
|
|
115
|
+
* following it, then add `0`. So `inc('1.2.3-beta', 'pre', 'beta')`
|
|
116
|
+
* would result in `1.2.3-beta.0`.
|
|
117
|
+
*
|
|
118
|
+
* - If no prerelease identifier is provided:
|
|
119
|
+
*
|
|
120
|
+
* If there is no current prerelease, then set the prerelease to `0`. So,
|
|
121
|
+
* `inc('1.2.3', 'pre')` becomes `1.2.3-0`.
|
|
122
|
+
*
|
|
123
|
+
* If the last item in the prerelease is numeric, then increment it. So,
|
|
124
|
+
* `inc('1.2.3-beta.3', 'pre')` becomes `1.2.3-beta.4`.
|
|
76
125
|
*/
|
|
77
126
|
inc(part: IncrementType, prereleaseIdentifier?: string): this;
|
|
78
127
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,YAAY,CAAA;AA2CvC;;GAEG;AACH,MAAM,MAAM,aAAa,GACrB,OAAO,GACP,OAAO,GACP,OAAO,GACP,KAAK,GACL,UAAU,GACV,UAAU,GACV,UAAU,GACV,YAAY,CAAA;AAEhB;;;;;GAKG;AACH,qBAAa,OAAO;IAClB,iDAAiD;IACjD,GAAG,EAAE,MAAM,CAAA;IAEX,4BAA4B;IAC5B,KAAK,EAAE,MAAM,CAAA;IACb,2BAA2B;IAC3B,KAAK,EAAE,MAAM,CAAA;IACb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,CAAA;IACb;;;;;OAKG;IACH,UAAU,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAA;IAChC;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;IAEhB,4CAA4C;IAC5C,QAAQ;IAMR,uDAAuD;IACvD,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,MAAM;gBA+C1B,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,KAAK,EAAE,MAAM,GAAG,SAAS;IA+B3B;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;IAiC/B;;OAEG;IACH,QAAQ,CAAC,CAAC,EAAE,OAAO;IAInB,6CAA6C;IAC7C,WAAW,CAAC,CAAC,EAAE,OAAO;IAItB,8CAA8C;IAC9C,gBAAgB,CAAC,CAAC,EAAE,OAAO;IAI3B,6CAA6C;IAC7C,QAAQ,CAAC,CAAC,EAAE,OAAO;IAInB,iDAAiD;IACjD,aAAa,CAAC,CAAC,EAAE,OAAO;IAIxB,8DAA8D;IAC9D,MAAM,CAAC,CAAC,EAAE,OAAO;IAIjB,kDAAkD;IAClD,WAAW,CAAC,CAAC,EAAE,OAAO;IAQtB,+CAA+C;IAC/C,SAAS,CAAC,CAAC,EAAE,KAAK;IAIlB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAqDG;IACH,GAAG,CAAC,IAAI,EAAE,aAAa,EAAE,oBAAoB,CAAC,EAAE,MAAM;CAiHvD"}
|
package/dist/esm/version.js
CHANGED
|
@@ -174,7 +174,7 @@ export class Version {
|
|
|
174
174
|
lessThan(v) {
|
|
175
175
|
return this.compare(v) === -1;
|
|
176
176
|
}
|
|
177
|
-
/** true if this version is
|
|
177
|
+
/** true if this version is <= the argument */
|
|
178
178
|
lessThanEqual(v) {
|
|
179
179
|
return this.compare(v) < 1;
|
|
180
180
|
}
|
|
@@ -195,7 +195,56 @@ export class Version {
|
|
|
195
195
|
/**
|
|
196
196
|
* Increment the version in place, in the manner specified.
|
|
197
197
|
*
|
|
198
|
-
*
|
|
198
|
+
* Part behaviors:
|
|
199
|
+
*
|
|
200
|
+
* - `'major'` If the version is a `M.0.0-...` version with a prerelease, then
|
|
201
|
+
* simply drop the prerelease. Otherwise, set the minor and patch to 0, and
|
|
202
|
+
* increment the major. So `1.0.0-beta` becomes `1.0.0`, and `1.2.3` becomes
|
|
203
|
+
* `2.0.0`
|
|
204
|
+
*
|
|
205
|
+
* - `'minor'` If the version is a `M.m.0-...` version with a prerelease, then
|
|
206
|
+
* simply drop the prerelease. Otherwise, set the patch to 0, and increment the
|
|
207
|
+
* minor. So `1.2.0-beta` becomes `1.2.0`, and `1.2.3` becomes `1.3.0`.
|
|
208
|
+
*
|
|
209
|
+
* - `'patch'` If the version has a prerelease, then simply drop the
|
|
210
|
+
* prerelease. Otherwise, increment the patch value. So `1.2.3-beta` becomes
|
|
211
|
+
* `1.2.3` and `1.2.3` becomes `1.2.4`.
|
|
212
|
+
*
|
|
213
|
+
* - `'premajor'` Set the patch and minor versions to `0`, increment the major
|
|
214
|
+
* version, and add a prerelease, using the optional identifier.
|
|
215
|
+
*
|
|
216
|
+
* - `'preminor'` Set the patch version to `0`, increment the minor version,
|
|
217
|
+
* and add a prerelease, using the optional identifier.
|
|
218
|
+
*
|
|
219
|
+
* - `'prepatch'` If a prerelease is already present, increment the patch
|
|
220
|
+
* version, otherwise leave it untouched, and add a prerelease, using the
|
|
221
|
+
* optional identifier.
|
|
222
|
+
*
|
|
223
|
+
* - `'prerelease'` If a prerelease version is present, then behave the same as
|
|
224
|
+
* `'prepatch'`. Otherwise, add a prerelease, using the optional identifier.
|
|
225
|
+
*
|
|
226
|
+
* - `'pre'` This is mostly for use by the other prerelease incrementers.
|
|
227
|
+
*
|
|
228
|
+
* - If a prerelease identifier is provided:
|
|
229
|
+
*
|
|
230
|
+
* Update that named portion of the prerelease. For example,
|
|
231
|
+
* `inc('1.2.3-beta.4', 'pre', 'beta')` would result in `1.2.3-beta.5`.
|
|
232
|
+
*
|
|
233
|
+
* If there is no prerelease identifier by that name, then replace the
|
|
234
|
+
* prerelease with `[name]`. So `inc('1.2.3-alpha.4', 'pre', 'beta')`
|
|
235
|
+
* would result in `1.2.3-beta`.
|
|
236
|
+
*
|
|
237
|
+
* If the prerelease identifer is present, but has no numeric value
|
|
238
|
+
* following it, then add `0`. So `inc('1.2.3-beta', 'pre', 'beta')`
|
|
239
|
+
* would result in `1.2.3-beta.0`.
|
|
240
|
+
*
|
|
241
|
+
* - If no prerelease identifier is provided:
|
|
242
|
+
*
|
|
243
|
+
* If there is no current prerelease, then set the prerelease to `0`. So,
|
|
244
|
+
* `inc('1.2.3', 'pre')` becomes `1.2.3-0`.
|
|
245
|
+
*
|
|
246
|
+
* If the last item in the prerelease is numeric, then increment it. So,
|
|
247
|
+
* `inc('1.2.3-beta.3', 'pre')` becomes `1.2.3-beta.4`.
|
|
199
248
|
*/
|
|
200
249
|
inc(part, prereleaseIdentifier) {
|
|
201
250
|
switch (part) {
|
package/dist/esm/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAG9C,MAAM,WAAW,GAAG,CAAC,CAAS,EAAmB,EAAE;IACjD,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;QAAE,OAAO,CAAC,CAAA;IACjC,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAA;IACnB,OAAO,CAAC,IAAI,MAAM,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EAAE,CAAC,CAAC,CAAA;gBACnC,MAAK;YACP,CAAC;YAED,KAAK,OAAO;gBACV,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK;oBACtD,IAAI,CAAC,KAAK,EAAE,CAAA;gBACd,IAAI,CAAC,UAAU,GAAG,SAAS,CAAA;gBAC3B,IAAI,CAAC,KAAK,GAAG,CAAC,CAAA;gBACd,IAAI,CAAC,KAAK,GAAG,CAAC,CAAA;gBACd,MAAK;YAEP,KAAK,OAAO;gBACV,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,IAAI,IAAI,CAAC,KAAK;oBAAE,IAAI,CAAC,KAAK,EAAE,CAAA;gBACxD,IAAI,CAAC,UAAU,GAAG,SAAS,CAAA;gBAC3B,IAAI,CAAC,KAAK,GAAG,CAAC,CAAA;gBACd,MAAK;YAEP,KAAK,OAAO;gBACV,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM;oBAAE,IAAI,CAAC,KAAK,EAAE,CAAA;gBAC1C,IAAI,CAAC,UAAU,GAAG,SAAS,CAAA;gBAC3B,MAAK;YAEP;gBACE,MAAM,SAAS,CACb,8BAA8B,EAC9B;oBACE,OAAO,EAAE,IAAI;oBACb,KAAK,EAAE,IAAI;oBACX,YAAY,EAAE;wBACZ,OAAO;wBACP,OAAO;wBACP,OAAO;wBACP,UAAU;wBACV,UAAU;wBACV,UAAU;wBACV,YAAY;wBACZ,KAAK;qBACN;iBACF,EACD,IAAI,CAAC,GAAG,CACT,CAAA;QACL,CAAC;QAED,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAA;QAC1B,OAAO,IAAI,CAAA;IACb,CAAC;CACF","sourcesContent":["import { syntaxError, typeError } from '@vltpkg/error-cause'\nimport { fastSplit } from '@vltpkg/fast-split'\nimport { type Range } from './range.js'\n\nconst maybeNumber = (s: string): number | string => {\n if (!/^[0-9]+$/.test(s)) return s\n const n = Number(s)\n return n <= Number.MAX_SAFE_INTEGER ? n : s\n}\n\nconst safeNumber = (\n s: string,\n version: string,\n field: string,\n): number => {\n const n = Number(s)\n if (n > Number.MAX_SAFE_INTEGER) {\n throw invalidVersion(\n version,\n `invalid ${field}, must be <= ${Number.MAX_SAFE_INTEGER}`,\n )\n }\n return n\n}\n\nconst re = {\n prefix: /^[ v=]+/,\n main: /^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)/,\n prerelease: /-([0-9a-zA-Z_.-]+)(?:$|\\+)/,\n build: /\\+([0-9a-zA-Z_.-]+)$/,\n full: /^[ v=]*(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-([0-9a-zA-Z_.-]+))?(?:\\+([0-9a-zA-Z_.-]+))?$/,\n} as const\n\nconst invalidVersion = (\n version: string,\n message: string,\n): SyntaxError => {\n const er = syntaxError(\n `invalid version: ${message}`,\n { version },\n Version,\n )\n return er\n}\n\n/**\n * Types of incrementing supported by {@link Version#inc}\n */\nexport type IncrementType =\n | 'major'\n | 'minor'\n | 'patch'\n | 'pre'\n | 'premajor'\n | 'preminor'\n | 'prepatch'\n | 'prerelease'\n\n/**\n * A parsed object representation of a SemVer version string\n *\n * This is a bit less forgiving than node-semver, in that prerelease versions\n * MUST start with '-'. Otherwise, the allowed syntax is identical.\n */\nexport class Version {\n /** raw string provided to create this Version */\n raw: string\n\n /** major version number */\n major: number\n /** minor version number */\n minor: number\n /** patch version number */\n patch: number\n /**\n * List of `'.'`-separated strings and numbers indicating that this\n * version is a prerelease.\n *\n * This is undefined if the version does not have a prerelease section.\n */\n prerelease?: (number | string)[]\n /**\n * List of `'.'`-separated strings in the `build` section.\n *\n * This is undefined if the version does not have a build.\n */\n build?: string[]\n\n /** Canonical strict form of this version */\n toString() {\n return `${this.major}.${this.minor}.${this.patch}${\n this.prerelease ? '-' + this.prerelease.join('.') : ''\n }${this.build ? '+' + this.build.join('.') : ''}`\n }\n\n /** Generate a `Version` object from a SemVer string */\n static parse(version: string) {\n version = version.replace(re.prefix, '').trim()\n if (version.length > 256) {\n throw invalidVersion(\n version,\n 'must be less than 256 characters',\n )\n }\n\n const parsed = version.match(re.full)\n if (!parsed) {\n const main = version.match(re.main)\n if (!main) {\n throw invalidVersion(\n version,\n 'no Major.minor.patch tuple present',\n )\n } else {\n throw invalidVersion(\n version,\n 'invalid build or patch section',\n )\n }\n }\n const [_, major_, minor_, patch_, prerelease, build] = parsed as [\n string,\n string,\n string,\n string,\n string | undefined,\n string | undefined,\n ]\n const major = safeNumber(major_, version, 'major')\n const minor = safeNumber(minor_, version, 'minor')\n const patch = safeNumber(patch_, version, 'patch')\n\n return new Version(\n version,\n major,\n minor,\n patch,\n prerelease,\n build,\n )\n }\n\n constructor(\n version: string,\n major: number,\n minor: number,\n patch: number,\n prerelease: string | undefined,\n build: string | undefined,\n ) {\n this.raw = version\n this.major = major\n this.minor = minor\n this.patch = patch\n\n // has prerelease and/or build\n if (prerelease) {\n this.prerelease = fastSplit(prerelease, '.', -1, c => {\n if (!c) {\n throw invalidVersion(\n version,\n 'invalid prerelease, empty identifiers not allowed',\n )\n }\n return maybeNumber(c)\n })\n }\n if (build) {\n this.build = fastSplit(build, '.', -1, c => {\n if (!c) {\n throw invalidVersion(\n version,\n 'invalid build metadata, empty identifiers not allowed',\n )\n }\n })\n }\n }\n\n /**\n * Return 1 if this is > the provided version, -1 if we're less, or 0 if\n * they are equal.\n *\n * No special handling for prerelease versions, this is just a precedence\n * comparison.\n *\n * This can be used to sort a list of versions by precedence:\n *\n * ```ts\n * const versions: Version[] = getVersionsSomehow()\n * const sorted = versions.sort((a, b) => a.compare(b))\n * ```\n */\n compare(v: Version): -1 | 0 | 1 {\n if (this.major > v.major) return 1\n if (this.major < v.major) return -1\n if (this.minor > v.minor) return 1\n if (this.minor < v.minor) return -1\n if (this.patch > v.patch) return 1\n if (this.patch < v.patch) return -1\n // main tuple is equal now\n // if the version has no pr, we're definitely less than or equal to\n if (!v.prerelease?.length)\n return !this.prerelease?.length ? 0 : -1\n // v has a pr. if we don't, we're > it\n if (!this.prerelease?.length) return 1\n // we both have prereleases\n const len = Math.max(this.prerelease.length, v.prerelease.length)\n const me = this.prerelease\n const thee = v.prerelease\n for (let i = 0; i < len; i++) {\n const m = me[i]\n const t = thee[i]\n if (m === t) continue\n // having a field is > not having it\n if (t === undefined) return 1\n if (m === undefined) return -1\n // string parts are higher precedence than\n if (typeof m !== typeof t) {\n return typeof m === 'string' ? 1 : -1\n }\n return m > t ? 1 : -1\n }\n return 0\n }\n\n /**\n * The inverse of compare, for sorting version lists in reverse order\n */\n rcompare(v: Version) {\n return -1 * this.compare(v)\n }\n\n /** true if this version is > the argument */\n greaterThan(v: Version) {\n return this.compare(v) === 1\n }\n\n /** true if this version is >= the argument */\n greaterThanEqual(v: Version) {\n return this.compare(v) > -1\n }\n\n /** true if this version is < the argument */\n lessThan(v: Version) {\n return this.compare(v) === -1\n }\n\n /** true if this version is <= the argument */\n lessThanEqual(v: Version) {\n return this.compare(v) < 1\n }\n\n /** true if these two versions have equal SemVer precedence */\n equals(v: Version) {\n return this.compare(v) === 0\n }\n\n /** just compare the M.m.p parts of the version */\n tupleEquals(v: Version) {\n return (\n this.major === v.major &&\n this.minor === v.minor &&\n this.patch === v.patch\n )\n }\n\n /** true if this version satisfies the range */\n satisfies(r: Range) {\n return r.test(this)\n }\n\n /**\n * Increment the version in place, in the manner specified.\n *\n * See {@link index.inc} for full description.\n */\n inc(part: IncrementType, prereleaseIdentifier?: string) {\n switch (part) {\n case 'premajor':\n this.prerelease = undefined\n this.patch = 0\n this.minor = 0\n this.major++\n this.inc('pre', prereleaseIdentifier)\n break\n\n case 'preminor':\n this.prerelease = undefined\n this.patch = 0\n this.minor++\n this.inc('pre', prereleaseIdentifier)\n break\n\n case 'prepatch':\n this.prerelease = undefined\n this.inc('patch')\n this.inc('pre', prereleaseIdentifier)\n break\n\n case 'prerelease':\n if (!this.prerelease?.length)\n this.inc('patch', prereleaseIdentifier)\n this.inc('pre', prereleaseIdentifier)\n break\n\n case 'pre': {\n // this is a bit different than node-semver's logic, but simpler\n // always do zero-based incrementing, and either bump the existing\n // numeric pr value, or add a `.0` after the identifier.\n if (!prereleaseIdentifier) {\n if (!this.prerelease?.length) {\n this.prerelease = [0]\n break\n }\n const last = this.prerelease[this.prerelease.length - 1]\n if (typeof last === 'number') {\n this.prerelease[this.prerelease.length - 1] = last + 1\n } else {\n this.prerelease.push(0)\n }\n break\n }\n if (!this.prerelease?.length) {\n this.prerelease = [prereleaseIdentifier]\n break\n }\n const i = this.prerelease.indexOf(\n maybeNumber(prereleaseIdentifier),\n )\n if (i === -1) {\n this.prerelease = [prereleaseIdentifier]\n break\n }\n const baseValue = this.prerelease[i + 1]\n if (typeof baseValue === 'number') {\n this.prerelease[i + 1] = baseValue + 1\n break\n }\n if (i === this.prerelease.length - 1) {\n this.prerelease.push(0)\n break\n }\n this.prerelease.splice(i + 1, 0, 0)\n break\n }\n\n case 'major':\n if (!this.prerelease?.length || this.minor || this.patch)\n this.major++\n this.prerelease = undefined\n this.patch = 0\n this.minor = 0\n break\n\n case 'minor':\n if (!this.prerelease?.length || this.patch) this.minor++\n this.prerelease = undefined\n this.patch = 0\n break\n\n case 'patch':\n if (!this.prerelease?.length) this.patch++\n this.prerelease = undefined\n break\n\n default:\n throw typeError(\n 'Invalid increment identifier',\n {\n version: this,\n found: part,\n validOptions: [\n 'major',\n 'minor',\n 'patch',\n 'premajor',\n 'preminor',\n 'prepatch',\n 'prerelease',\n 'pre',\n ],\n },\n this.inc,\n )\n }\n\n this.raw = this.toString()\n return this\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAG9C,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GAAG,CACT,CAAA;QACL,CAAC;QAED,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAA;QAC1B,OAAO,IAAI,CAAA;IACb,CAAC;CACF","sourcesContent":["import { syntaxError, typeError } from '@vltpkg/error-cause'\nimport { fastSplit } from '@vltpkg/fast-split'\nimport { type Range } from './range.js'\n\nconst maybeNumber = (s: string): number | string => {\n if (!/^[0-9]+$/.test(s)) return s\n const n = Number(s)\n return n <= Number.MAX_SAFE_INTEGER ? n : s\n}\n\nconst safeNumber = (\n s: string,\n version: string,\n field: string,\n): number => {\n const n = Number(s)\n if (n > Number.MAX_SAFE_INTEGER) {\n throw invalidVersion(\n version,\n `invalid ${field}, must be <= ${Number.MAX_SAFE_INTEGER}`,\n )\n }\n return n\n}\n\nconst re = {\n prefix: /^[ v=]+/,\n main: /^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)/,\n prerelease: /-([0-9a-zA-Z_.-]+)(?:$|\\+)/,\n build: /\\+([0-9a-zA-Z_.-]+)$/,\n full: /^[ v=]*(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-([0-9a-zA-Z_.-]+))?(?:\\+([0-9a-zA-Z_.-]+))?$/,\n} as const\n\nconst invalidVersion = (\n version: string,\n message: string,\n): SyntaxError => {\n const er = syntaxError(\n `invalid version: ${message}`,\n { version },\n Version,\n )\n return er\n}\n\n/**\n * Types of incrementing supported by {@link Version#inc}\n */\nexport type IncrementType =\n | 'major'\n | 'minor'\n | 'patch'\n | 'pre'\n | 'premajor'\n | 'preminor'\n | 'prepatch'\n | 'prerelease'\n\n/**\n * A parsed object representation of a SemVer version string\n *\n * This is a bit less forgiving than node-semver, in that prerelease versions\n * MUST start with '-'. Otherwise, the allowed syntax is identical.\n */\nexport class Version {\n /** raw string provided to create this Version */\n raw: string\n\n /** major version number */\n major: number\n /** minor version number */\n minor: number\n /** patch version number */\n patch: number\n /**\n * List of `'.'`-separated strings and numbers indicating that this\n * version is a prerelease.\n *\n * This is undefined if the version does not have a prerelease section.\n */\n prerelease?: (number | string)[]\n /**\n * List of `'.'`-separated strings in the `build` section.\n *\n * This is undefined if the version does not have a build.\n */\n build?: string[]\n\n /** Canonical strict form of this version */\n toString() {\n return `${this.major}.${this.minor}.${this.patch}${\n this.prerelease ? '-' + this.prerelease.join('.') : ''\n }${this.build ? '+' + this.build.join('.') : ''}`\n }\n\n /** Generate a `Version` object from a SemVer string */\n static parse(version: string) {\n version = version.replace(re.prefix, '').trim()\n if (version.length > 256) {\n throw invalidVersion(\n version,\n 'must be less than 256 characters',\n )\n }\n\n const parsed = version.match(re.full)\n if (!parsed) {\n const main = version.match(re.main)\n if (!main) {\n throw invalidVersion(\n version,\n 'no Major.minor.patch tuple present',\n )\n } else {\n throw invalidVersion(\n version,\n 'invalid build or patch section',\n )\n }\n }\n const [_, major_, minor_, patch_, prerelease, build] = parsed as [\n string,\n string,\n string,\n string,\n string | undefined,\n string | undefined,\n ]\n const major = safeNumber(major_, version, 'major')\n const minor = safeNumber(minor_, version, 'minor')\n const patch = safeNumber(patch_, version, 'patch')\n\n return new Version(\n version,\n major,\n minor,\n patch,\n prerelease,\n build,\n )\n }\n\n constructor(\n version: string,\n major: number,\n minor: number,\n patch: number,\n prerelease: string | undefined,\n build: string | undefined,\n ) {\n this.raw = version\n this.major = major\n this.minor = minor\n this.patch = patch\n\n // has prerelease and/or build\n if (prerelease) {\n this.prerelease = fastSplit(prerelease, '.', -1, c => {\n if (!c) {\n throw invalidVersion(\n version,\n 'invalid prerelease, empty identifiers not allowed',\n )\n }\n return maybeNumber(c)\n })\n }\n if (build) {\n this.build = fastSplit(build, '.', -1, c => {\n if (!c) {\n throw invalidVersion(\n version,\n 'invalid build metadata, empty identifiers not allowed',\n )\n }\n })\n }\n }\n\n /**\n * Return 1 if this is > the provided version, -1 if we're less, or 0 if\n * they are equal.\n *\n * No special handling for prerelease versions, this is just a precedence\n * comparison.\n *\n * This can be used to sort a list of versions by precedence:\n *\n * ```ts\n * const versions: Version[] = getVersionsSomehow()\n * const sorted = versions.sort((a, b) => a.compare(b))\n * ```\n */\n compare(v: Version): -1 | 0 | 1 {\n if (this.major > v.major) return 1\n if (this.major < v.major) return -1\n if (this.minor > v.minor) return 1\n if (this.minor < v.minor) return -1\n if (this.patch > v.patch) return 1\n if (this.patch < v.patch) return -1\n // main tuple is equal now\n // if the version has no pr, we're definitely less than or equal to\n if (!v.prerelease?.length)\n return !this.prerelease?.length ? 0 : -1\n // v has a pr. if we don't, we're > it\n if (!this.prerelease?.length) return 1\n // we both have prereleases\n const len = Math.max(this.prerelease.length, v.prerelease.length)\n const me = this.prerelease\n const thee = v.prerelease\n for (let i = 0; i < len; i++) {\n const m = me[i]\n const t = thee[i]\n if (m === t) continue\n // having a field is > not having it\n if (t === undefined) return 1\n if (m === undefined) return -1\n // string parts are higher precedence than\n if (typeof m !== typeof t) {\n return typeof m === 'string' ? 1 : -1\n }\n return m > t ? 1 : -1\n }\n return 0\n }\n\n /**\n * The inverse of compare, for sorting version lists in reverse order\n */\n rcompare(v: Version) {\n return -1 * this.compare(v)\n }\n\n /** true if this version is > the argument */\n greaterThan(v: Version) {\n return this.compare(v) === 1\n }\n\n /** true if this version is >= the argument */\n greaterThanEqual(v: Version) {\n return this.compare(v) > -1\n }\n\n /** true if this version is < the argument */\n lessThan(v: Version) {\n return this.compare(v) === -1\n }\n\n /** true if this version is <= the argument */\n lessThanEqual(v: Version) {\n return this.compare(v) < 1\n }\n\n /** true if these two versions have equal SemVer precedence */\n equals(v: Version) {\n return this.compare(v) === 0\n }\n\n /** just compare the M.m.p parts of the version */\n tupleEquals(v: Version) {\n return (\n this.major === v.major &&\n this.minor === v.minor &&\n this.patch === v.patch\n )\n }\n\n /** true if this version satisfies the range */\n satisfies(r: Range) {\n return r.test(this)\n }\n\n /**\n * Increment the version in place, in the manner specified.\n *\n * Part behaviors:\n *\n * - `'major'` If the version is a `M.0.0-...` version with a prerelease, then\n * simply drop the prerelease. Otherwise, set the minor and patch to 0, and\n * increment the major. So `1.0.0-beta` becomes `1.0.0`, and `1.2.3` becomes\n * `2.0.0`\n *\n * - `'minor'` If the version is a `M.m.0-...` version with a prerelease, then\n * simply drop the prerelease. Otherwise, set the patch to 0, and increment the\n * minor. So `1.2.0-beta` becomes `1.2.0`, and `1.2.3` becomes `1.3.0`.\n *\n * - `'patch'` If the version has a prerelease, then simply drop the\n * prerelease. Otherwise, increment the patch value. So `1.2.3-beta` becomes\n * `1.2.3` and `1.2.3` becomes `1.2.4`.\n *\n * - `'premajor'` Set the patch and minor versions to `0`, increment the major\n * version, and add a prerelease, using the optional identifier.\n *\n * - `'preminor'` Set the patch version to `0`, increment the minor version,\n * and add a prerelease, using the optional identifier.\n *\n * - `'prepatch'` If a prerelease is already present, increment the patch\n * version, otherwise leave it untouched, and add a prerelease, using the\n * optional identifier.\n *\n * - `'prerelease'` If a prerelease version is present, then behave the same as\n * `'prepatch'`. Otherwise, add a prerelease, using the optional identifier.\n *\n * - `'pre'` This is mostly for use by the other prerelease incrementers.\n *\n * - If a prerelease identifier is provided:\n *\n * Update that named portion of the prerelease. For example,\n * `inc('1.2.3-beta.4', 'pre', 'beta')` would result in `1.2.3-beta.5`.\n *\n * If there is no prerelease identifier by that name, then replace the\n * prerelease with `[name]`. So `inc('1.2.3-alpha.4', 'pre', 'beta')`\n * would result in `1.2.3-beta`.\n *\n * If the prerelease identifer is present, but has no numeric value\n * following it, then add `0`. So `inc('1.2.3-beta', 'pre', 'beta')`\n * would result in `1.2.3-beta.0`.\n *\n * - If no prerelease identifier is provided:\n *\n * If there is no current prerelease, then set the prerelease to `0`. So,\n * `inc('1.2.3', 'pre')` becomes `1.2.3-0`.\n *\n * If the last item in the prerelease is numeric, then increment it. So,\n * `inc('1.2.3-beta.3', 'pre')` becomes `1.2.3-beta.4`.\n */\n inc(part: IncrementType, prereleaseIdentifier?: string) {\n switch (part) {\n case 'premajor':\n this.prerelease = undefined\n this.patch = 0\n this.minor = 0\n this.major++\n this.inc('pre', prereleaseIdentifier)\n break\n\n case 'preminor':\n this.prerelease = undefined\n this.patch = 0\n this.minor++\n this.inc('pre', prereleaseIdentifier)\n break\n\n case 'prepatch':\n this.prerelease = undefined\n this.inc('patch')\n this.inc('pre', prereleaseIdentifier)\n break\n\n case 'prerelease':\n if (!this.prerelease?.length)\n this.inc('patch', prereleaseIdentifier)\n this.inc('pre', prereleaseIdentifier)\n break\n\n case 'pre': {\n // this is a bit different than node-semver's logic, but simpler\n // always do zero-based incrementing, and either bump the existing\n // numeric pr value, or add a `.0` after the identifier.\n if (!prereleaseIdentifier) {\n if (!this.prerelease?.length) {\n this.prerelease = [0]\n break\n }\n const last = this.prerelease[this.prerelease.length - 1]\n if (typeof last === 'number') {\n this.prerelease[this.prerelease.length - 1] = last + 1\n } else {\n this.prerelease.push(0)\n }\n break\n }\n if (!this.prerelease?.length) {\n this.prerelease = [prereleaseIdentifier]\n break\n }\n const i = this.prerelease.indexOf(\n maybeNumber(prereleaseIdentifier),\n )\n if (i === -1) {\n this.prerelease = [prereleaseIdentifier]\n break\n }\n const baseValue = this.prerelease[i + 1]\n if (typeof baseValue === 'number') {\n this.prerelease[i + 1] = baseValue + 1\n break\n }\n if (i === this.prerelease.length - 1) {\n this.prerelease.push(0)\n break\n }\n this.prerelease.splice(i + 1, 0, 0)\n break\n }\n\n case 'major':\n if (!this.prerelease?.length || this.minor || this.patch)\n this.major++\n this.prerelease = undefined\n this.patch = 0\n this.minor = 0\n break\n\n case 'minor':\n if (!this.prerelease?.length || this.patch) this.minor++\n this.prerelease = undefined\n this.patch = 0\n break\n\n case 'patch':\n if (!this.prerelease?.length) this.patch++\n this.prerelease = undefined\n break\n\n default:\n throw typeError(\n 'Invalid increment identifier',\n {\n version: this,\n found: part,\n validOptions: [\n 'major',\n 'minor',\n 'patch',\n 'premajor',\n 'preminor',\n 'prepatch',\n 'prerelease',\n 'pre',\n ],\n },\n this.inc,\n )\n }\n\n this.raw = this.toString()\n return this\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vltpkg/semver",
|
|
3
3
|
"description": "The semantic version parser used by vlt",
|
|
4
|
-
"version": "0.0.0-0.
|
|
4
|
+
"version": "0.0.0-0.1730724342581",
|
|
5
5
|
"tshy": {
|
|
6
6
|
"selfLink": false,
|
|
7
7
|
"dialects": [
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@vltpkg/error-cause": "0.0.0-0.
|
|
17
|
-
"@vltpkg/fast-split": "0.0.0-0.
|
|
16
|
+
"@vltpkg/error-cause": "0.0.0-0.1730724342581",
|
|
17
|
+
"@vltpkg/fast-split": "0.0.0-0.1730724342581"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"@eslint/js": "^9.8.0",
|