semver 6.2.0 → 7.1.1
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/CHANGELOG.md +38 -0
- package/README.md +58 -2
- package/bin/semver.js +78 -79
- package/classes/comparator.js +139 -0
- package/classes/index.js +5 -0
- package/classes/range.js +448 -0
- package/classes/semver.js +290 -0
- package/functions/clean.js +6 -0
- package/functions/cmp.js +48 -0
- package/functions/coerce.js +51 -0
- package/functions/compare-build.js +7 -0
- package/functions/compare-loose.js +3 -0
- package/functions/compare.js +5 -0
- package/functions/diff.js +25 -0
- package/functions/eq.js +3 -0
- package/functions/gt.js +3 -0
- package/functions/gte.js +3 -0
- package/functions/inc.js +15 -0
- package/functions/lt.js +3 -0
- package/functions/lte.js +3 -0
- package/functions/major.js +3 -0
- package/functions/minor.js +3 -0
- package/functions/neq.js +3 -0
- package/functions/parse.js +37 -0
- package/functions/patch.js +3 -0
- package/functions/prerelease.js +6 -0
- package/functions/rcompare.js +3 -0
- package/functions/rsort.js +3 -0
- package/functions/satisfies.js +10 -0
- package/functions/sort.js +3 -0
- package/functions/valid.js +6 -0
- package/index.js +64 -0
- package/internal/constants.js +17 -0
- package/internal/debug.js +9 -0
- package/internal/identifiers.js +23 -0
- package/internal/re.js +179 -0
- package/package.json +15 -5
- package/preload.js +46 -0
- package/ranges/gtr.js +4 -0
- package/ranges/intersects.js +7 -0
- package/ranges/ltr.js +4 -0
- package/ranges/max-satisfying.js +25 -0
- package/ranges/min-satisfying.js +24 -0
- package/ranges/min-version.js +57 -0
- package/ranges/outside.js +80 -0
- package/ranges/to-comparators.js +8 -0
- package/ranges/valid.js +11 -0
- package/bin/.semver.js.swp +0 -0
- package/semver.js +0 -1589
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
const debug = require('../internal/debug')
|
|
2
|
+
const { MAX_LENGTH, MAX_SAFE_INTEGER } = require('../internal/constants')
|
|
3
|
+
const { re, t } = require('../internal/re')
|
|
4
|
+
|
|
5
|
+
const { compareIdentifiers } = require('../internal/identifiers')
|
|
6
|
+
class SemVer {
|
|
7
|
+
constructor (version, options) {
|
|
8
|
+
if (!options || typeof options !== 'object') {
|
|
9
|
+
options = {
|
|
10
|
+
loose: !!options,
|
|
11
|
+
includePrerelease: false
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
if (version instanceof SemVer) {
|
|
15
|
+
if (version.loose === !!options.loose &&
|
|
16
|
+
version.includePrerelease === !!options.includePrerelease) {
|
|
17
|
+
return version
|
|
18
|
+
} else {
|
|
19
|
+
version = version.version
|
|
20
|
+
}
|
|
21
|
+
} else if (typeof version !== 'string') {
|
|
22
|
+
throw new TypeError(`Invalid Version: ${version}`)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (version.length > MAX_LENGTH) {
|
|
26
|
+
throw new TypeError(
|
|
27
|
+
`version is longer than ${MAX_LENGTH} characters`
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
debug('SemVer', version, options)
|
|
32
|
+
this.options = options
|
|
33
|
+
this.loose = !!options.loose
|
|
34
|
+
// this isn't actually relevant for versions, but keep it so that we
|
|
35
|
+
// don't run into trouble passing this.options around.
|
|
36
|
+
this.includePrerelease = !!options.includePrerelease
|
|
37
|
+
|
|
38
|
+
const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL])
|
|
39
|
+
|
|
40
|
+
if (!m) {
|
|
41
|
+
throw new TypeError(`Invalid Version: ${version}`)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
this.raw = version
|
|
45
|
+
|
|
46
|
+
// these are actually numbers
|
|
47
|
+
this.major = +m[1]
|
|
48
|
+
this.minor = +m[2]
|
|
49
|
+
this.patch = +m[3]
|
|
50
|
+
|
|
51
|
+
if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
|
|
52
|
+
throw new TypeError('Invalid major version')
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
|
|
56
|
+
throw new TypeError('Invalid minor version')
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
|
|
60
|
+
throw new TypeError('Invalid patch version')
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// numberify any prerelease numeric ids
|
|
64
|
+
if (!m[4]) {
|
|
65
|
+
this.prerelease = []
|
|
66
|
+
} else {
|
|
67
|
+
this.prerelease = m[4].split('.').map((id) => {
|
|
68
|
+
if (/^[0-9]+$/.test(id)) {
|
|
69
|
+
const num = +id
|
|
70
|
+
if (num >= 0 && num < MAX_SAFE_INTEGER) {
|
|
71
|
+
return num
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return id
|
|
75
|
+
})
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
this.build = m[5] ? m[5].split('.') : []
|
|
79
|
+
this.format()
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
format () {
|
|
83
|
+
this.version = `${this.major}.${this.minor}.${this.patch}`
|
|
84
|
+
if (this.prerelease.length) {
|
|
85
|
+
this.version += `-${this.prerelease.join('.')}`
|
|
86
|
+
}
|
|
87
|
+
return this.version
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
toString () {
|
|
91
|
+
return this.version
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
compare (other) {
|
|
95
|
+
debug('SemVer.compare', this.version, this.options, other)
|
|
96
|
+
if (!(other instanceof SemVer)) {
|
|
97
|
+
if (typeof other === 'string' && other === this.version) {
|
|
98
|
+
return 0
|
|
99
|
+
}
|
|
100
|
+
other = new SemVer(other, this.options)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (other.version === this.version) {
|
|
104
|
+
return 0
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return this.compareMain(other) || this.comparePre(other)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
compareMain (other) {
|
|
111
|
+
if (!(other instanceof SemVer)) {
|
|
112
|
+
other = new SemVer(other, this.options)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return (
|
|
116
|
+
compareIdentifiers(this.major, other.major) ||
|
|
117
|
+
compareIdentifiers(this.minor, other.minor) ||
|
|
118
|
+
compareIdentifiers(this.patch, other.patch)
|
|
119
|
+
)
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
comparePre (other) {
|
|
123
|
+
if (!(other instanceof SemVer)) {
|
|
124
|
+
other = new SemVer(other, this.options)
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// NOT having a prerelease is > having one
|
|
128
|
+
if (this.prerelease.length && !other.prerelease.length) {
|
|
129
|
+
return -1
|
|
130
|
+
} else if (!this.prerelease.length && other.prerelease.length) {
|
|
131
|
+
return 1
|
|
132
|
+
} else if (!this.prerelease.length && !other.prerelease.length) {
|
|
133
|
+
return 0
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
let i = 0
|
|
137
|
+
do {
|
|
138
|
+
const a = this.prerelease[i]
|
|
139
|
+
const b = other.prerelease[i]
|
|
140
|
+
debug('prerelease compare', i, a, b)
|
|
141
|
+
if (a === undefined && b === undefined) {
|
|
142
|
+
return 0
|
|
143
|
+
} else if (b === undefined) {
|
|
144
|
+
return 1
|
|
145
|
+
} else if (a === undefined) {
|
|
146
|
+
return -1
|
|
147
|
+
} else if (a === b) {
|
|
148
|
+
continue
|
|
149
|
+
} else {
|
|
150
|
+
return compareIdentifiers(a, b)
|
|
151
|
+
}
|
|
152
|
+
} while (++i)
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
compareBuild (other) {
|
|
156
|
+
if (!(other instanceof SemVer)) {
|
|
157
|
+
other = new SemVer(other, this.options)
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
let i = 0
|
|
161
|
+
do {
|
|
162
|
+
const a = this.build[i]
|
|
163
|
+
const b = other.build[i]
|
|
164
|
+
debug('prerelease compare', i, a, b)
|
|
165
|
+
if (a === undefined && b === undefined) {
|
|
166
|
+
return 0
|
|
167
|
+
} else if (b === undefined) {
|
|
168
|
+
return 1
|
|
169
|
+
} else if (a === undefined) {
|
|
170
|
+
return -1
|
|
171
|
+
} else if (a === b) {
|
|
172
|
+
continue
|
|
173
|
+
} else {
|
|
174
|
+
return compareIdentifiers(a, b)
|
|
175
|
+
}
|
|
176
|
+
} while (++i)
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// preminor will bump the version up to the next minor release, and immediately
|
|
180
|
+
// down to pre-release. premajor and prepatch work the same way.
|
|
181
|
+
inc (release, identifier) {
|
|
182
|
+
switch (release) {
|
|
183
|
+
case 'premajor':
|
|
184
|
+
this.prerelease.length = 0
|
|
185
|
+
this.patch = 0
|
|
186
|
+
this.minor = 0
|
|
187
|
+
this.major++
|
|
188
|
+
this.inc('pre', identifier)
|
|
189
|
+
break
|
|
190
|
+
case 'preminor':
|
|
191
|
+
this.prerelease.length = 0
|
|
192
|
+
this.patch = 0
|
|
193
|
+
this.minor++
|
|
194
|
+
this.inc('pre', identifier)
|
|
195
|
+
break
|
|
196
|
+
case 'prepatch':
|
|
197
|
+
// If this is already a prerelease, it will bump to the next version
|
|
198
|
+
// drop any prereleases that might already exist, since they are not
|
|
199
|
+
// relevant at this point.
|
|
200
|
+
this.prerelease.length = 0
|
|
201
|
+
this.inc('patch', identifier)
|
|
202
|
+
this.inc('pre', identifier)
|
|
203
|
+
break
|
|
204
|
+
// If the input is a non-prerelease version, this acts the same as
|
|
205
|
+
// prepatch.
|
|
206
|
+
case 'prerelease':
|
|
207
|
+
if (this.prerelease.length === 0) {
|
|
208
|
+
this.inc('patch', identifier)
|
|
209
|
+
}
|
|
210
|
+
this.inc('pre', identifier)
|
|
211
|
+
break
|
|
212
|
+
|
|
213
|
+
case 'major':
|
|
214
|
+
// If this is a pre-major version, bump up to the same major version.
|
|
215
|
+
// Otherwise increment major.
|
|
216
|
+
// 1.0.0-5 bumps to 1.0.0
|
|
217
|
+
// 1.1.0 bumps to 2.0.0
|
|
218
|
+
if (
|
|
219
|
+
this.minor !== 0 ||
|
|
220
|
+
this.patch !== 0 ||
|
|
221
|
+
this.prerelease.length === 0
|
|
222
|
+
) {
|
|
223
|
+
this.major++
|
|
224
|
+
}
|
|
225
|
+
this.minor = 0
|
|
226
|
+
this.patch = 0
|
|
227
|
+
this.prerelease = []
|
|
228
|
+
break
|
|
229
|
+
case 'minor':
|
|
230
|
+
// If this is a pre-minor version, bump up to the same minor version.
|
|
231
|
+
// Otherwise increment minor.
|
|
232
|
+
// 1.2.0-5 bumps to 1.2.0
|
|
233
|
+
// 1.2.1 bumps to 1.3.0
|
|
234
|
+
if (this.patch !== 0 || this.prerelease.length === 0) {
|
|
235
|
+
this.minor++
|
|
236
|
+
}
|
|
237
|
+
this.patch = 0
|
|
238
|
+
this.prerelease = []
|
|
239
|
+
break
|
|
240
|
+
case 'patch':
|
|
241
|
+
// If this is not a pre-release version, it will increment the patch.
|
|
242
|
+
// If it is a pre-release it will bump up to the same patch version.
|
|
243
|
+
// 1.2.0-5 patches to 1.2.0
|
|
244
|
+
// 1.2.0 patches to 1.2.1
|
|
245
|
+
if (this.prerelease.length === 0) {
|
|
246
|
+
this.patch++
|
|
247
|
+
}
|
|
248
|
+
this.prerelease = []
|
|
249
|
+
break
|
|
250
|
+
// This probably shouldn't be used publicly.
|
|
251
|
+
// 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
|
|
252
|
+
case 'pre':
|
|
253
|
+
if (this.prerelease.length === 0) {
|
|
254
|
+
this.prerelease = [0]
|
|
255
|
+
} else {
|
|
256
|
+
let i = this.prerelease.length
|
|
257
|
+
while (--i >= 0) {
|
|
258
|
+
if (typeof this.prerelease[i] === 'number') {
|
|
259
|
+
this.prerelease[i]++
|
|
260
|
+
i = -2
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
if (i === -1) {
|
|
264
|
+
// didn't increment anything
|
|
265
|
+
this.prerelease.push(0)
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
if (identifier) {
|
|
269
|
+
// 1.2.0-beta.1 bumps to 1.2.0-beta.2,
|
|
270
|
+
// 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
|
|
271
|
+
if (this.prerelease[0] === identifier) {
|
|
272
|
+
if (isNaN(this.prerelease[1])) {
|
|
273
|
+
this.prerelease = [identifier, 0]
|
|
274
|
+
}
|
|
275
|
+
} else {
|
|
276
|
+
this.prerelease = [identifier, 0]
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
break
|
|
280
|
+
|
|
281
|
+
default:
|
|
282
|
+
throw new Error(`invalid increment argument: ${release}`)
|
|
283
|
+
}
|
|
284
|
+
this.format()
|
|
285
|
+
this.raw = this.version
|
|
286
|
+
return this
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
module.exports = SemVer
|
package/functions/cmp.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
const eq = require('./eq')
|
|
2
|
+
const neq = require('./neq')
|
|
3
|
+
const gt = require('./gt')
|
|
4
|
+
const gte = require('./gte')
|
|
5
|
+
const lt = require('./lt')
|
|
6
|
+
const lte = require('./lte')
|
|
7
|
+
|
|
8
|
+
const cmp = (a, op, b, loose) => {
|
|
9
|
+
switch (op) {
|
|
10
|
+
case '===':
|
|
11
|
+
if (typeof a === 'object')
|
|
12
|
+
a = a.version
|
|
13
|
+
if (typeof b === 'object')
|
|
14
|
+
b = b.version
|
|
15
|
+
return a === b
|
|
16
|
+
|
|
17
|
+
case '!==':
|
|
18
|
+
if (typeof a === 'object')
|
|
19
|
+
a = a.version
|
|
20
|
+
if (typeof b === 'object')
|
|
21
|
+
b = b.version
|
|
22
|
+
return a !== b
|
|
23
|
+
|
|
24
|
+
case '':
|
|
25
|
+
case '=':
|
|
26
|
+
case '==':
|
|
27
|
+
return eq(a, b, loose)
|
|
28
|
+
|
|
29
|
+
case '!=':
|
|
30
|
+
return neq(a, b, loose)
|
|
31
|
+
|
|
32
|
+
case '>':
|
|
33
|
+
return gt(a, b, loose)
|
|
34
|
+
|
|
35
|
+
case '>=':
|
|
36
|
+
return gte(a, b, loose)
|
|
37
|
+
|
|
38
|
+
case '<':
|
|
39
|
+
return lt(a, b, loose)
|
|
40
|
+
|
|
41
|
+
case '<=':
|
|
42
|
+
return lte(a, b, loose)
|
|
43
|
+
|
|
44
|
+
default:
|
|
45
|
+
throw new TypeError(`Invalid operator: ${op}`)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
module.exports = cmp
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
const SemVer = require('../classes/semver')
|
|
2
|
+
const parse = require('./parse')
|
|
3
|
+
const {re, t} = require('../internal/re')
|
|
4
|
+
|
|
5
|
+
const coerce = (version, options) => {
|
|
6
|
+
if (version instanceof SemVer) {
|
|
7
|
+
return version
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
if (typeof version === 'number') {
|
|
11
|
+
version = String(version)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (typeof version !== 'string') {
|
|
15
|
+
return null
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
options = options || {}
|
|
19
|
+
|
|
20
|
+
let match = null
|
|
21
|
+
if (!options.rtl) {
|
|
22
|
+
match = version.match(re[t.COERCE])
|
|
23
|
+
} else {
|
|
24
|
+
// Find the right-most coercible string that does not share
|
|
25
|
+
// a terminus with a more left-ward coercible string.
|
|
26
|
+
// Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4'
|
|
27
|
+
//
|
|
28
|
+
// Walk through the string checking with a /g regexp
|
|
29
|
+
// Manually set the index so as to pick up overlapping matches.
|
|
30
|
+
// Stop when we get a match that ends at the string end, since no
|
|
31
|
+
// coercible string can be more right-ward without the same terminus.
|
|
32
|
+
let next
|
|
33
|
+
while ((next = re[t.COERCERTL].exec(version)) &&
|
|
34
|
+
(!match || match.index + match[0].length !== version.length)
|
|
35
|
+
) {
|
|
36
|
+
if (!match ||
|
|
37
|
+
next.index + next[0].length !== match.index + match[0].length) {
|
|
38
|
+
match = next
|
|
39
|
+
}
|
|
40
|
+
re[t.COERCERTL].lastIndex = next.index + next[1].length + next[2].length
|
|
41
|
+
}
|
|
42
|
+
// leave it in a clean state
|
|
43
|
+
re[t.COERCERTL].lastIndex = -1
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (match === null)
|
|
47
|
+
return null
|
|
48
|
+
|
|
49
|
+
return parse(`${match[2]}.${match[3] || '0'}.${match[4] || '0'}`, options)
|
|
50
|
+
}
|
|
51
|
+
module.exports = coerce
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
const SemVer = require('../classes/semver')
|
|
2
|
+
const compareBuild = (a, b, loose) => {
|
|
3
|
+
const versionA = new SemVer(a, loose)
|
|
4
|
+
const versionB = new SemVer(b, loose)
|
|
5
|
+
return versionA.compare(versionB) || versionA.compareBuild(versionB)
|
|
6
|
+
}
|
|
7
|
+
module.exports = compareBuild
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const parse = require('./parse')
|
|
2
|
+
const eq = require('./eq')
|
|
3
|
+
|
|
4
|
+
const diff = (version1, version2) => {
|
|
5
|
+
if (eq(version1, version2)) {
|
|
6
|
+
return null
|
|
7
|
+
} else {
|
|
8
|
+
const v1 = parse(version1)
|
|
9
|
+
const v2 = parse(version2)
|
|
10
|
+
let prefix = ''
|
|
11
|
+
if (v1.prerelease.length || v2.prerelease.length) {
|
|
12
|
+
prefix = 'pre'
|
|
13
|
+
var defaultResult = 'prerelease'
|
|
14
|
+
}
|
|
15
|
+
for (const key in v1) {
|
|
16
|
+
if (key === 'major' || key === 'minor' || key === 'patch') {
|
|
17
|
+
if (v1[key] !== v2[key]) {
|
|
18
|
+
return prefix + key
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return defaultResult // may be undefined
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
module.exports = diff
|
package/functions/eq.js
ADDED
package/functions/gt.js
ADDED
package/functions/gte.js
ADDED
package/functions/inc.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const SemVer = require('../classes/semver')
|
|
2
|
+
|
|
3
|
+
const inc = (version, release, options, identifier) => {
|
|
4
|
+
if (typeof (options) === 'string') {
|
|
5
|
+
identifier = options
|
|
6
|
+
options = undefined
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
try {
|
|
10
|
+
return new SemVer(version, options).inc(release, identifier).version
|
|
11
|
+
} catch (er) {
|
|
12
|
+
return null
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
module.exports = inc
|
package/functions/lt.js
ADDED
package/functions/lte.js
ADDED
package/functions/neq.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const {MAX_LENGTH} = require('../internal/constants')
|
|
2
|
+
const { re, t } = require('../internal/re')
|
|
3
|
+
const SemVer = require('../classes/semver')
|
|
4
|
+
|
|
5
|
+
const parse = (version, options) => {
|
|
6
|
+
if (!options || typeof options !== 'object') {
|
|
7
|
+
options = {
|
|
8
|
+
loose: !!options,
|
|
9
|
+
includePrerelease: false
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
if (version instanceof SemVer) {
|
|
14
|
+
return version
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (typeof version !== 'string') {
|
|
18
|
+
return null
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (version.length > MAX_LENGTH) {
|
|
22
|
+
return null
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const r = options.loose ? re[t.LOOSE] : re[t.FULL]
|
|
26
|
+
if (!r.test(version)) {
|
|
27
|
+
return null
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
try {
|
|
31
|
+
return new SemVer(version, options)
|
|
32
|
+
} catch (er) {
|
|
33
|
+
return null
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
module.exports = parse
|
package/index.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
const lrCache = {}
|
|
2
|
+
const lazyRequire = (path, subkey) => {
|
|
3
|
+
const module = lrCache[path] || (lrCache[path] = require(path))
|
|
4
|
+
return subkey ? module[subkey] : module
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
const lazyExport = (key, path, subkey) => {
|
|
8
|
+
Object.defineProperty(exports, key, {
|
|
9
|
+
get: () => {
|
|
10
|
+
const res = lazyRequire(path, subkey)
|
|
11
|
+
Object.defineProperty(exports, key, {
|
|
12
|
+
value: res,
|
|
13
|
+
enumerable: true,
|
|
14
|
+
configurable: true
|
|
15
|
+
})
|
|
16
|
+
return res
|
|
17
|
+
},
|
|
18
|
+
configurable: true,
|
|
19
|
+
enumerable: true
|
|
20
|
+
})
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
lazyExport('re', './internal/re', 're')
|
|
24
|
+
lazyExport('src', './internal/re', 'src')
|
|
25
|
+
lazyExport('tokens', './internal/re', 't')
|
|
26
|
+
lazyExport('SEMVER_SPEC_VERSION', './internal/constants', 'SEMVER_SPEC_VERSION')
|
|
27
|
+
lazyExport('SemVer', './classes/semver')
|
|
28
|
+
lazyExport('compareIdentifiers', './internal/identifiers', 'compareIdentifiers')
|
|
29
|
+
lazyExport('rcompareIdentifiers', './internal/identifiers', 'rcompareIdentifiers')
|
|
30
|
+
lazyExport('parse', './functions/parse')
|
|
31
|
+
lazyExport('valid', './functions/valid')
|
|
32
|
+
lazyExport('clean', './functions/clean')
|
|
33
|
+
lazyExport('inc', './functions/inc')
|
|
34
|
+
lazyExport('diff', './functions/diff')
|
|
35
|
+
lazyExport('major', './functions/major')
|
|
36
|
+
lazyExport('minor', './functions/minor')
|
|
37
|
+
lazyExport('patch', './functions/patch')
|
|
38
|
+
lazyExport('prerelease', './functions/prerelease')
|
|
39
|
+
lazyExport('compare', './functions/compare')
|
|
40
|
+
lazyExport('rcompare', './functions/rcompare')
|
|
41
|
+
lazyExport('compareLoose', './functions/compare-loose')
|
|
42
|
+
lazyExport('compareBuild', './functions/compare-build')
|
|
43
|
+
lazyExport('sort', './functions/sort')
|
|
44
|
+
lazyExport('rsort', './functions/rsort')
|
|
45
|
+
lazyExport('gt', './functions/gt')
|
|
46
|
+
lazyExport('lt', './functions/lt')
|
|
47
|
+
lazyExport('eq', './functions/eq')
|
|
48
|
+
lazyExport('neq', './functions/neq')
|
|
49
|
+
lazyExport('gte', './functions/gte')
|
|
50
|
+
lazyExport('lte', './functions/lte')
|
|
51
|
+
lazyExport('cmp', './functions/cmp')
|
|
52
|
+
lazyExport('coerce', './functions/coerce')
|
|
53
|
+
lazyExport('Comparator', './classes/comparator')
|
|
54
|
+
lazyExport('Range', './classes/range')
|
|
55
|
+
lazyExport('satisfies', './functions/satisfies')
|
|
56
|
+
lazyExport('toComparators', './ranges/to-comparators')
|
|
57
|
+
lazyExport('maxSatisfying', './ranges/max-satisfying')
|
|
58
|
+
lazyExport('minSatisfying', './ranges/min-satisfying')
|
|
59
|
+
lazyExport('minVersion', './ranges/min-version')
|
|
60
|
+
lazyExport('validRange', './ranges/valid')
|
|
61
|
+
lazyExport('outside', './ranges/outside')
|
|
62
|
+
lazyExport('gtr', './ranges/gtr')
|
|
63
|
+
lazyExport('ltr', './ranges/ltr')
|
|
64
|
+
lazyExport('intersects', './ranges/intersects')
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Note: this is the semver.org version of the spec that it implements
|
|
2
|
+
// Not necessarily the package version of this code.
|
|
3
|
+
const SEMVER_SPEC_VERSION = '2.0.0'
|
|
4
|
+
|
|
5
|
+
const MAX_LENGTH = 256
|
|
6
|
+
const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER ||
|
|
7
|
+
/* istanbul ignore next */ 9007199254740991
|
|
8
|
+
|
|
9
|
+
// Max safe segment length for coercion.
|
|
10
|
+
const MAX_SAFE_COMPONENT_LENGTH = 16
|
|
11
|
+
|
|
12
|
+
module.exports = {
|
|
13
|
+
SEMVER_SPEC_VERSION,
|
|
14
|
+
MAX_LENGTH,
|
|
15
|
+
MAX_SAFE_INTEGER,
|
|
16
|
+
MAX_SAFE_COMPONENT_LENGTH
|
|
17
|
+
}
|