fsevents 1.2.7 → 1.2.8
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.
Potentially problematic release.
This version of fsevents might be problematic. Click here for more details.
- package/.travis.yml +0 -2
- package/node_modules/abbrev/package.json +2 -3
- package/node_modules/ansi-regex/package.json +1 -1
- package/node_modules/aproba/package.json +1 -1
- package/node_modules/are-we-there-yet/package.json +1 -1
- package/node_modules/balanced-match/package.json +1 -1
- package/node_modules/brace-expansion/package.json +1 -1
- package/node_modules/chownr/package.json +1 -1
- package/node_modules/code-point-at/package.json +1 -1
- package/node_modules/concat-map/package.json +1 -1
- package/node_modules/console-control-strings/package.json +1 -1
- package/node_modules/core-util-is/package.json +1 -1
- package/node_modules/debug/CHANGELOG.md +34 -1
- package/node_modules/debug/README.md +206 -63
- package/node_modules/debug/dist/debug.js +912 -0
- package/node_modules/debug/package.json +40 -26
- package/node_modules/debug/src/browser.js +185 -106
- package/node_modules/debug/src/common.js +266 -0
- package/node_modules/debug/src/index.js +4 -4
- package/node_modules/debug/src/node.js +174 -165
- package/node_modules/deep-extend/package.json +1 -1
- package/node_modules/delegates/package.json +1 -1
- package/node_modules/detect-libc/package.json +1 -1
- package/node_modules/fs-minipass/package.json +1 -1
- package/node_modules/fs.realpath/package.json +1 -1
- package/node_modules/gauge/package.json +1 -1
- package/node_modules/glob/package.json +1 -1
- package/node_modules/has-unicode/package.json +1 -1
- package/node_modules/iconv-lite/package.json +1 -1
- package/node_modules/ignore-walk/package.json +1 -1
- package/node_modules/inflight/package.json +1 -1
- package/node_modules/inherits/package.json +2 -4
- package/node_modules/ini/package.json +1 -1
- package/node_modules/is-fullwidth-code-point/package.json +1 -1
- package/node_modules/isarray/package.json +1 -1
- package/node_modules/minimatch/package.json +1 -1
- package/node_modules/minimist/package.json +1 -1
- package/node_modules/minipass/package.json +1 -1
- package/node_modules/minizlib/package.json +1 -1
- package/node_modules/mkdirp/package.json +1 -2
- package/node_modules/ms/index.js +28 -18
- package/node_modules/ms/package.json +17 -17
- package/node_modules/ms/readme.md +17 -8
- package/node_modules/needle/.npmignore +6 -0
- package/node_modules/needle/README.md +1 -2
- package/node_modules/needle/examples/multipart-stream.js +1 -1
- package/node_modules/needle/lib/auth.js +1 -1
- package/node_modules/needle/lib/multipart.js +1 -1
- package/node_modules/needle/lib/needle.js +2 -2
- package/node_modules/needle/package-lock.json +395 -0
- package/node_modules/needle/package.json +13 -13
- package/node_modules/needle/test/basic_auth_spec.js +1 -1
- package/node_modules/needle/test/cookies_spec.js +2 -2
- package/node_modules/needle/test/keys/ssl.cert +21 -0
- package/node_modules/needle/test/keys/ssl.key +27 -0
- package/node_modules/needle/test/output_spec.js +1 -1
- package/node_modules/needle/test/post_data_spec.js +20 -20
- package/node_modules/needle/test/proxy_spec.js +1 -1
- package/node_modules/needle/test/utils/test.js +1 -1
- package/node_modules/node-pre-gyp/CHANGELOG.md +10 -0
- package/node_modules/node-pre-gyp/README.md +41 -6
- package/node_modules/node-pre-gyp/lib/build.js +1 -1
- package/node_modules/node-pre-gyp/lib/install.js +20 -8
- package/node_modules/node-pre-gyp/lib/node-pre-gyp.js +1 -1
- package/node_modules/node-pre-gyp/lib/pre-binding.js +5 -5
- package/node_modules/node-pre-gyp/lib/rebuild.js +1 -1
- package/node_modules/node-pre-gyp/lib/reinstall.js +1 -1
- package/node_modules/node-pre-gyp/lib/util/abi_crosswalk.json +48 -0
- package/node_modules/node-pre-gyp/lib/util/handle_gyp_opts.js +5 -2
- package/node_modules/node-pre-gyp/lib/util/napi.js +70 -22
- package/node_modules/node-pre-gyp/lib/util/versioning.js +7 -6
- package/node_modules/node-pre-gyp/package.json +13 -12
- package/node_modules/nopt/package.json +1 -1
- package/node_modules/npm-bundled/index.js +13 -1
- package/node_modules/npm-bundled/package.json +6 -6
- package/node_modules/npm-packlist/index.js +29 -8
- package/node_modules/npm-packlist/package.json +6 -6
- package/node_modules/npmlog/package.json +1 -1
- package/node_modules/number-is-nan/package.json +1 -1
- package/node_modules/object-assign/package.json +1 -1
- package/node_modules/once/package.json +1 -1
- package/node_modules/os-homedir/package.json +1 -1
- package/node_modules/os-tmpdir/package.json +1 -1
- package/node_modules/osenv/package.json +1 -1
- package/node_modules/path-is-absolute/package.json +1 -1
- package/node_modules/process-nextick-args/package.json +1 -1
- package/node_modules/rc/node_modules/minimist/package.json +1 -1
- package/node_modules/rc/package.json +1 -1
- package/node_modules/readable-stream/package.json +1 -1
- package/node_modules/rimraf/package.json +1 -1
- package/node_modules/safe-buffer/package.json +1 -1
- package/node_modules/safer-buffer/package.json +1 -1
- package/node_modules/sax/package.json +1 -1
- package/node_modules/semver/CHANGELOG.md +39 -0
- package/node_modules/semver/README.md +14 -2
- package/node_modules/semver/bin/semver +84 -77
- package/node_modules/semver/package.json +14 -8
- package/node_modules/semver/semver.js +906 -775
- package/node_modules/set-blocking/package.json +1 -1
- package/node_modules/signal-exit/package.json +1 -1
- package/node_modules/string-width/package.json +1 -1
- package/node_modules/string_decoder/package.json +1 -1
- package/node_modules/strip-ansi/package.json +1 -1
- package/node_modules/strip-json-comments/package.json +1 -1
- package/node_modules/tar/package.json +1 -1
- package/node_modules/util-deprecate/package.json +1 -1
- package/node_modules/wide-align/package.json +1 -1
- package/node_modules/wrappy/package.json +1 -1
- package/node_modules/yallist/package.json +1 -1
- package/package.json +5 -8
- package/node_modules/debug/.coveralls.yml +0 -1
- package/node_modules/debug/.eslintrc +0 -11
- package/node_modules/debug/.npmignore +0 -9
- package/node_modules/debug/.travis.yml +0 -14
- package/node_modules/debug/Makefile +0 -50
- package/node_modules/debug/component.json +0 -19
- package/node_modules/debug/karma.conf.js +0 -70
- package/node_modules/debug/node.js +0 -1
- package/node_modules/debug/src/debug.js +0 -202
- package/node_modules/debug/src/inspector-log.js +0 -15
- package/node_modules/needle/note.xml +0 -7
- package/node_modules/needle/note.xml.1 +0 -7
@@ -1,33 +1,35 @@
|
|
1
|
-
exports = module.exports = SemVer
|
2
|
-
|
3
|
-
|
4
|
-
/*
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
1
|
+
exports = module.exports = SemVer
|
2
|
+
|
3
|
+
var debug
|
4
|
+
/* istanbul ignore next */
|
5
|
+
if (typeof process === 'object' &&
|
6
|
+
process.env &&
|
7
|
+
process.env.NODE_DEBUG &&
|
8
|
+
/\bsemver\b/i.test(process.env.NODE_DEBUG)) {
|
9
|
+
debug = function () {
|
10
|
+
var args = Array.prototype.slice.call(arguments, 0)
|
11
|
+
args.unshift('SEMVER')
|
12
|
+
console.log.apply(console, args)
|
13
|
+
}
|
14
|
+
} else {
|
15
|
+
debug = function () {}
|
16
|
+
}
|
16
17
|
|
17
18
|
// Note: this is the semver.org version of the spec that it implements
|
18
19
|
// Not necessarily the package version of this code.
|
19
|
-
exports.SEMVER_SPEC_VERSION = '2.0.0'
|
20
|
+
exports.SEMVER_SPEC_VERSION = '2.0.0'
|
20
21
|
|
21
|
-
var MAX_LENGTH = 256
|
22
|
-
var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER ||
|
22
|
+
var MAX_LENGTH = 256
|
23
|
+
var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER ||
|
24
|
+
/* istanbul ignore next */ 9007199254740991
|
23
25
|
|
24
26
|
// Max safe segment length for coercion.
|
25
|
-
var MAX_SAFE_COMPONENT_LENGTH = 16
|
27
|
+
var MAX_SAFE_COMPONENT_LENGTH = 16
|
26
28
|
|
27
29
|
// The actual regexps go on exports.re
|
28
|
-
var re = exports.re = []
|
29
|
-
var src = exports.src = []
|
30
|
-
var R = 0
|
30
|
+
var re = exports.re = []
|
31
|
+
var src = exports.src = []
|
32
|
+
var R = 0
|
31
33
|
|
32
34
|
// The following Regular Expressions can be used for tokenizing,
|
33
35
|
// validating, and parsing SemVer version strings.
|
@@ -35,71 +37,67 @@ var R = 0;
|
|
35
37
|
// ## Numeric Identifier
|
36
38
|
// A single `0`, or a non-zero digit followed by zero or more digits.
|
37
39
|
|
38
|
-
var NUMERICIDENTIFIER = R
|
39
|
-
src[NUMERICIDENTIFIER] = '0|[1-9]\\d*'
|
40
|
-
var NUMERICIDENTIFIERLOOSE = R
|
41
|
-
src[NUMERICIDENTIFIERLOOSE] = '[0-9]+'
|
42
|
-
|
40
|
+
var NUMERICIDENTIFIER = R++
|
41
|
+
src[NUMERICIDENTIFIER] = '0|[1-9]\\d*'
|
42
|
+
var NUMERICIDENTIFIERLOOSE = R++
|
43
|
+
src[NUMERICIDENTIFIERLOOSE] = '[0-9]+'
|
43
44
|
|
44
45
|
// ## Non-numeric Identifier
|
45
46
|
// Zero or more digits, followed by a letter or hyphen, and then zero or
|
46
47
|
// more letters, digits, or hyphens.
|
47
48
|
|
48
|
-
var NONNUMERICIDENTIFIER = R
|
49
|
-
src[NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*'
|
50
|
-
|
49
|
+
var NONNUMERICIDENTIFIER = R++
|
50
|
+
src[NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*'
|
51
51
|
|
52
52
|
// ## Main Version
|
53
53
|
// Three dot-separated numeric identifiers.
|
54
54
|
|
55
|
-
var MAINVERSION = R
|
55
|
+
var MAINVERSION = R++
|
56
56
|
src[MAINVERSION] = '(' + src[NUMERICIDENTIFIER] + ')\\.' +
|
57
57
|
'(' + src[NUMERICIDENTIFIER] + ')\\.' +
|
58
|
-
'(' + src[NUMERICIDENTIFIER] + ')'
|
58
|
+
'(' + src[NUMERICIDENTIFIER] + ')'
|
59
59
|
|
60
|
-
var MAINVERSIONLOOSE = R
|
60
|
+
var MAINVERSIONLOOSE = R++
|
61
61
|
src[MAINVERSIONLOOSE] = '(' + src[NUMERICIDENTIFIERLOOSE] + ')\\.' +
|
62
62
|
'(' + src[NUMERICIDENTIFIERLOOSE] + ')\\.' +
|
63
|
-
'(' + src[NUMERICIDENTIFIERLOOSE] + ')'
|
63
|
+
'(' + src[NUMERICIDENTIFIERLOOSE] + ')'
|
64
64
|
|
65
65
|
// ## Pre-release Version Identifier
|
66
66
|
// A numeric identifier, or a non-numeric identifier.
|
67
67
|
|
68
|
-
var PRERELEASEIDENTIFIER = R
|
68
|
+
var PRERELEASEIDENTIFIER = R++
|
69
69
|
src[PRERELEASEIDENTIFIER] = '(?:' + src[NUMERICIDENTIFIER] +
|
70
|
-
'|' + src[NONNUMERICIDENTIFIER] + ')'
|
70
|
+
'|' + src[NONNUMERICIDENTIFIER] + ')'
|
71
71
|
|
72
|
-
var PRERELEASEIDENTIFIERLOOSE = R
|
72
|
+
var PRERELEASEIDENTIFIERLOOSE = R++
|
73
73
|
src[PRERELEASEIDENTIFIERLOOSE] = '(?:' + src[NUMERICIDENTIFIERLOOSE] +
|
74
|
-
'|' + src[NONNUMERICIDENTIFIER] + ')'
|
75
|
-
|
74
|
+
'|' + src[NONNUMERICIDENTIFIER] + ')'
|
76
75
|
|
77
76
|
// ## Pre-release Version
|
78
77
|
// Hyphen, followed by one or more dot-separated pre-release version
|
79
78
|
// identifiers.
|
80
79
|
|
81
|
-
var PRERELEASE = R
|
80
|
+
var PRERELEASE = R++
|
82
81
|
src[PRERELEASE] = '(?:-(' + src[PRERELEASEIDENTIFIER] +
|
83
|
-
'(?:\\.' + src[PRERELEASEIDENTIFIER] + ')*))'
|
82
|
+
'(?:\\.' + src[PRERELEASEIDENTIFIER] + ')*))'
|
84
83
|
|
85
|
-
var PRERELEASELOOSE = R
|
84
|
+
var PRERELEASELOOSE = R++
|
86
85
|
src[PRERELEASELOOSE] = '(?:-?(' + src[PRERELEASEIDENTIFIERLOOSE] +
|
87
|
-
'(?:\\.' + src[PRERELEASEIDENTIFIERLOOSE] + ')*))'
|
86
|
+
'(?:\\.' + src[PRERELEASEIDENTIFIERLOOSE] + ')*))'
|
88
87
|
|
89
88
|
// ## Build Metadata Identifier
|
90
89
|
// Any combination of digits, letters, or hyphens.
|
91
90
|
|
92
|
-
var BUILDIDENTIFIER = R
|
93
|
-
src[BUILDIDENTIFIER] = '[0-9A-Za-z-]+'
|
91
|
+
var BUILDIDENTIFIER = R++
|
92
|
+
src[BUILDIDENTIFIER] = '[0-9A-Za-z-]+'
|
94
93
|
|
95
94
|
// ## Build Metadata
|
96
95
|
// Plus sign, followed by one or more period-separated build metadata
|
97
96
|
// identifiers.
|
98
97
|
|
99
|
-
var BUILD = R
|
98
|
+
var BUILD = R++
|
100
99
|
src[BUILD] = '(?:\\+(' + src[BUILDIDENTIFIER] +
|
101
|
-
'(?:\\.' + src[BUILDIDENTIFIER] + ')*))'
|
102
|
-
|
100
|
+
'(?:\\.' + src[BUILDIDENTIFIER] + ')*))'
|
103
101
|
|
104
102
|
// ## Full Version String
|
105
103
|
// A main version, followed optionally by a pre-release version and
|
@@ -110,802 +108,870 @@ src[BUILD] = '(?:\\+(' + src[BUILDIDENTIFIER] +
|
|
110
108
|
// capturing group, because it should not ever be used in version
|
111
109
|
// comparison.
|
112
110
|
|
113
|
-
var FULL = R
|
111
|
+
var FULL = R++
|
114
112
|
var FULLPLAIN = 'v?' + src[MAINVERSION] +
|
115
113
|
src[PRERELEASE] + '?' +
|
116
|
-
src[BUILD] + '?'
|
114
|
+
src[BUILD] + '?'
|
117
115
|
|
118
|
-
src[FULL] = '^' + FULLPLAIN + '$'
|
116
|
+
src[FULL] = '^' + FULLPLAIN + '$'
|
119
117
|
|
120
118
|
// like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
|
121
119
|
// also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
|
122
120
|
// common in the npm registry.
|
123
121
|
var LOOSEPLAIN = '[v=\\s]*' + src[MAINVERSIONLOOSE] +
|
124
122
|
src[PRERELEASELOOSE] + '?' +
|
125
|
-
src[BUILD] + '?'
|
123
|
+
src[BUILD] + '?'
|
126
124
|
|
127
|
-
var LOOSE = R
|
128
|
-
src[LOOSE] = '^' + LOOSEPLAIN + '$'
|
125
|
+
var LOOSE = R++
|
126
|
+
src[LOOSE] = '^' + LOOSEPLAIN + '$'
|
129
127
|
|
130
|
-
var GTLT = R
|
131
|
-
src[GTLT] = '((?:<|>)?=?)'
|
128
|
+
var GTLT = R++
|
129
|
+
src[GTLT] = '((?:<|>)?=?)'
|
132
130
|
|
133
131
|
// Something like "2.*" or "1.2.x".
|
134
132
|
// Note that "x.x" is a valid xRange identifer, meaning "any version"
|
135
133
|
// Only the first item is strictly required.
|
136
|
-
var XRANGEIDENTIFIERLOOSE = R
|
137
|
-
src[XRANGEIDENTIFIERLOOSE] = src[NUMERICIDENTIFIERLOOSE] + '|x|X|\\*'
|
138
|
-
var XRANGEIDENTIFIER = R
|
139
|
-
src[XRANGEIDENTIFIER] = src[NUMERICIDENTIFIER] + '|x|X|\\*'
|
134
|
+
var XRANGEIDENTIFIERLOOSE = R++
|
135
|
+
src[XRANGEIDENTIFIERLOOSE] = src[NUMERICIDENTIFIERLOOSE] + '|x|X|\\*'
|
136
|
+
var XRANGEIDENTIFIER = R++
|
137
|
+
src[XRANGEIDENTIFIER] = src[NUMERICIDENTIFIER] + '|x|X|\\*'
|
140
138
|
|
141
|
-
var XRANGEPLAIN = R
|
139
|
+
var XRANGEPLAIN = R++
|
142
140
|
src[XRANGEPLAIN] = '[v=\\s]*(' + src[XRANGEIDENTIFIER] + ')' +
|
143
141
|
'(?:\\.(' + src[XRANGEIDENTIFIER] + ')' +
|
144
142
|
'(?:\\.(' + src[XRANGEIDENTIFIER] + ')' +
|
145
143
|
'(?:' + src[PRERELEASE] + ')?' +
|
146
144
|
src[BUILD] + '?' +
|
147
|
-
')?)?'
|
145
|
+
')?)?'
|
148
146
|
|
149
|
-
var XRANGEPLAINLOOSE = R
|
147
|
+
var XRANGEPLAINLOOSE = R++
|
150
148
|
src[XRANGEPLAINLOOSE] = '[v=\\s]*(' + src[XRANGEIDENTIFIERLOOSE] + ')' +
|
151
149
|
'(?:\\.(' + src[XRANGEIDENTIFIERLOOSE] + ')' +
|
152
150
|
'(?:\\.(' + src[XRANGEIDENTIFIERLOOSE] + ')' +
|
153
151
|
'(?:' + src[PRERELEASELOOSE] + ')?' +
|
154
152
|
src[BUILD] + '?' +
|
155
|
-
')?)?'
|
153
|
+
')?)?'
|
156
154
|
|
157
|
-
var XRANGE = R
|
158
|
-
src[XRANGE] = '^' + src[GTLT] + '\\s*' + src[XRANGEPLAIN] + '$'
|
159
|
-
var XRANGELOOSE = R
|
160
|
-
src[XRANGELOOSE] = '^' + src[GTLT] + '\\s*' + src[XRANGEPLAINLOOSE] + '$'
|
155
|
+
var XRANGE = R++
|
156
|
+
src[XRANGE] = '^' + src[GTLT] + '\\s*' + src[XRANGEPLAIN] + '$'
|
157
|
+
var XRANGELOOSE = R++
|
158
|
+
src[XRANGELOOSE] = '^' + src[GTLT] + '\\s*' + src[XRANGEPLAINLOOSE] + '$'
|
161
159
|
|
162
160
|
// Coercion.
|
163
161
|
// Extract anything that could conceivably be a part of a valid semver
|
164
|
-
var COERCE = R
|
162
|
+
var COERCE = R++
|
165
163
|
src[COERCE] = '(?:^|[^\\d])' +
|
166
164
|
'(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '})' +
|
167
165
|
'(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' +
|
168
166
|
'(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' +
|
169
|
-
'(?:$|[^\\d])'
|
167
|
+
'(?:$|[^\\d])'
|
170
168
|
|
171
169
|
// Tilde ranges.
|
172
170
|
// Meaning is "reasonably at or greater than"
|
173
|
-
var LONETILDE = R
|
174
|
-
src[LONETILDE] = '(?:~>?)'
|
171
|
+
var LONETILDE = R++
|
172
|
+
src[LONETILDE] = '(?:~>?)'
|
175
173
|
|
176
|
-
var TILDETRIM = R
|
177
|
-
src[TILDETRIM] = '(\\s*)' + src[LONETILDE] + '\\s+'
|
178
|
-
re[TILDETRIM] = new RegExp(src[TILDETRIM], 'g')
|
179
|
-
var tildeTrimReplace = '$1~'
|
174
|
+
var TILDETRIM = R++
|
175
|
+
src[TILDETRIM] = '(\\s*)' + src[LONETILDE] + '\\s+'
|
176
|
+
re[TILDETRIM] = new RegExp(src[TILDETRIM], 'g')
|
177
|
+
var tildeTrimReplace = '$1~'
|
180
178
|
|
181
|
-
var TILDE = R
|
182
|
-
src[TILDE] = '^' + src[LONETILDE] + src[XRANGEPLAIN] + '$'
|
183
|
-
var TILDELOOSE = R
|
184
|
-
src[TILDELOOSE] = '^' + src[LONETILDE] + src[XRANGEPLAINLOOSE] + '$'
|
179
|
+
var TILDE = R++
|
180
|
+
src[TILDE] = '^' + src[LONETILDE] + src[XRANGEPLAIN] + '$'
|
181
|
+
var TILDELOOSE = R++
|
182
|
+
src[TILDELOOSE] = '^' + src[LONETILDE] + src[XRANGEPLAINLOOSE] + '$'
|
185
183
|
|
186
184
|
// Caret ranges.
|
187
185
|
// Meaning is "at least and backwards compatible with"
|
188
|
-
var LONECARET = R
|
189
|
-
src[LONECARET] = '(?:\\^)'
|
186
|
+
var LONECARET = R++
|
187
|
+
src[LONECARET] = '(?:\\^)'
|
190
188
|
|
191
|
-
var CARETTRIM = R
|
192
|
-
src[CARETTRIM] = '(\\s*)' + src[LONECARET] + '\\s+'
|
193
|
-
re[CARETTRIM] = new RegExp(src[CARETTRIM], 'g')
|
194
|
-
var caretTrimReplace = '$1^'
|
189
|
+
var CARETTRIM = R++
|
190
|
+
src[CARETTRIM] = '(\\s*)' + src[LONECARET] + '\\s+'
|
191
|
+
re[CARETTRIM] = new RegExp(src[CARETTRIM], 'g')
|
192
|
+
var caretTrimReplace = '$1^'
|
195
193
|
|
196
|
-
var CARET = R
|
197
|
-
src[CARET] = '^' + src[LONECARET] + src[XRANGEPLAIN] + '$'
|
198
|
-
var CARETLOOSE = R
|
199
|
-
src[CARETLOOSE] = '^' + src[LONECARET] + src[XRANGEPLAINLOOSE] + '$'
|
194
|
+
var CARET = R++
|
195
|
+
src[CARET] = '^' + src[LONECARET] + src[XRANGEPLAIN] + '$'
|
196
|
+
var CARETLOOSE = R++
|
197
|
+
src[CARETLOOSE] = '^' + src[LONECARET] + src[XRANGEPLAINLOOSE] + '$'
|
200
198
|
|
201
199
|
// A simple gt/lt/eq thing, or just "" to indicate "any version"
|
202
|
-
var COMPARATORLOOSE = R
|
203
|
-
src[COMPARATORLOOSE] = '^' + src[GTLT] + '\\s*(' + LOOSEPLAIN + ')$|^$'
|
204
|
-
var COMPARATOR = R
|
205
|
-
src[COMPARATOR] = '^' + src[GTLT] + '\\s*(' + FULLPLAIN + ')$|^$'
|
206
|
-
|
200
|
+
var COMPARATORLOOSE = R++
|
201
|
+
src[COMPARATORLOOSE] = '^' + src[GTLT] + '\\s*(' + LOOSEPLAIN + ')$|^$'
|
202
|
+
var COMPARATOR = R++
|
203
|
+
src[COMPARATOR] = '^' + src[GTLT] + '\\s*(' + FULLPLAIN + ')$|^$'
|
207
204
|
|
208
205
|
// An expression to strip any whitespace between the gtlt and the thing
|
209
206
|
// it modifies, so that `> 1.2.3` ==> `>1.2.3`
|
210
|
-
var COMPARATORTRIM = R
|
207
|
+
var COMPARATORTRIM = R++
|
211
208
|
src[COMPARATORTRIM] = '(\\s*)' + src[GTLT] +
|
212
|
-
'\\s*(' + LOOSEPLAIN + '|' + src[XRANGEPLAIN] + ')'
|
209
|
+
'\\s*(' + LOOSEPLAIN + '|' + src[XRANGEPLAIN] + ')'
|
213
210
|
|
214
211
|
// this one has to use the /g flag
|
215
|
-
re[COMPARATORTRIM] = new RegExp(src[COMPARATORTRIM], 'g')
|
216
|
-
var comparatorTrimReplace = '$1$2$3'
|
217
|
-
|
212
|
+
re[COMPARATORTRIM] = new RegExp(src[COMPARATORTRIM], 'g')
|
213
|
+
var comparatorTrimReplace = '$1$2$3'
|
218
214
|
|
219
215
|
// Something like `1.2.3 - 1.2.4`
|
220
216
|
// Note that these all use the loose form, because they'll be
|
221
217
|
// checked against either the strict or loose comparator form
|
222
218
|
// later.
|
223
|
-
var HYPHENRANGE = R
|
219
|
+
var HYPHENRANGE = R++
|
224
220
|
src[HYPHENRANGE] = '^\\s*(' + src[XRANGEPLAIN] + ')' +
|
225
221
|
'\\s+-\\s+' +
|
226
222
|
'(' + src[XRANGEPLAIN] + ')' +
|
227
|
-
'\\s*$'
|
223
|
+
'\\s*$'
|
228
224
|
|
229
|
-
var HYPHENRANGELOOSE = R
|
225
|
+
var HYPHENRANGELOOSE = R++
|
230
226
|
src[HYPHENRANGELOOSE] = '^\\s*(' + src[XRANGEPLAINLOOSE] + ')' +
|
231
227
|
'\\s+-\\s+' +
|
232
228
|
'(' + src[XRANGEPLAINLOOSE] + ')' +
|
233
|
-
'\\s*$'
|
229
|
+
'\\s*$'
|
234
230
|
|
235
231
|
// Star ranges basically just allow anything at all.
|
236
|
-
var STAR = R
|
237
|
-
src[STAR] = '(<|>)?=?\\s*\\*'
|
232
|
+
var STAR = R++
|
233
|
+
src[STAR] = '(<|>)?=?\\s*\\*'
|
238
234
|
|
239
235
|
// Compile to actual regexp objects.
|
240
236
|
// All are flag-free, unless they were created above with a flag.
|
241
237
|
for (var i = 0; i < R; i++) {
|
242
|
-
debug(i, src[i])
|
243
|
-
if (!re[i])
|
244
|
-
re[i] = new RegExp(src[i])
|
238
|
+
debug(i, src[i])
|
239
|
+
if (!re[i]) {
|
240
|
+
re[i] = new RegExp(src[i])
|
241
|
+
}
|
245
242
|
}
|
246
243
|
|
247
|
-
exports.parse = parse
|
248
|
-
function parse(version, options) {
|
249
|
-
if (!options || typeof options !== 'object')
|
250
|
-
options = {
|
244
|
+
exports.parse = parse
|
245
|
+
function parse (version, options) {
|
246
|
+
if (!options || typeof options !== 'object') {
|
247
|
+
options = {
|
248
|
+
loose: !!options,
|
249
|
+
includePrerelease: false
|
250
|
+
}
|
251
|
+
}
|
251
252
|
|
252
|
-
if (version instanceof SemVer)
|
253
|
-
return version
|
253
|
+
if (version instanceof SemVer) {
|
254
|
+
return version
|
255
|
+
}
|
254
256
|
|
255
|
-
if (typeof version !== 'string')
|
256
|
-
return null
|
257
|
+
if (typeof version !== 'string') {
|
258
|
+
return null
|
259
|
+
}
|
257
260
|
|
258
|
-
if (version.length > MAX_LENGTH)
|
259
|
-
return null
|
261
|
+
if (version.length > MAX_LENGTH) {
|
262
|
+
return null
|
263
|
+
}
|
260
264
|
|
261
|
-
var r = options.loose ? re[LOOSE] : re[FULL]
|
262
|
-
if (!r.test(version))
|
263
|
-
return null
|
265
|
+
var r = options.loose ? re[LOOSE] : re[FULL]
|
266
|
+
if (!r.test(version)) {
|
267
|
+
return null
|
268
|
+
}
|
264
269
|
|
265
270
|
try {
|
266
|
-
return new SemVer(version, options)
|
271
|
+
return new SemVer(version, options)
|
267
272
|
} catch (er) {
|
268
|
-
return null
|
273
|
+
return null
|
269
274
|
}
|
270
275
|
}
|
271
276
|
|
272
|
-
exports.valid = valid
|
273
|
-
function valid(version, options) {
|
274
|
-
var v = parse(version, options)
|
275
|
-
return v ? v.version : null
|
277
|
+
exports.valid = valid
|
278
|
+
function valid (version, options) {
|
279
|
+
var v = parse(version, options)
|
280
|
+
return v ? v.version : null
|
276
281
|
}
|
277
282
|
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
return s ? s.version : null;
|
283
|
+
exports.clean = clean
|
284
|
+
function clean (version, options) {
|
285
|
+
var s = parse(version.trim().replace(/^[=v]+/, ''), options)
|
286
|
+
return s ? s.version : null
|
283
287
|
}
|
284
288
|
|
285
|
-
exports.SemVer = SemVer
|
289
|
+
exports.SemVer = SemVer
|
286
290
|
|
287
|
-
function SemVer(version, options) {
|
288
|
-
if (!options || typeof options !== 'object')
|
289
|
-
options = {
|
291
|
+
function SemVer (version, options) {
|
292
|
+
if (!options || typeof options !== 'object') {
|
293
|
+
options = {
|
294
|
+
loose: !!options,
|
295
|
+
includePrerelease: false
|
296
|
+
}
|
297
|
+
}
|
290
298
|
if (version instanceof SemVer) {
|
291
|
-
if (version.loose === options.loose)
|
292
|
-
return version
|
293
|
-
else
|
294
|
-
version = version.version
|
299
|
+
if (version.loose === options.loose) {
|
300
|
+
return version
|
301
|
+
} else {
|
302
|
+
version = version.version
|
303
|
+
}
|
295
304
|
} else if (typeof version !== 'string') {
|
296
|
-
throw new TypeError('Invalid Version: ' + version)
|
305
|
+
throw new TypeError('Invalid Version: ' + version)
|
297
306
|
}
|
298
307
|
|
299
|
-
if (version.length > MAX_LENGTH)
|
308
|
+
if (version.length > MAX_LENGTH) {
|
300
309
|
throw new TypeError('version is longer than ' + MAX_LENGTH + ' characters')
|
310
|
+
}
|
301
311
|
|
302
|
-
if (!(this instanceof SemVer))
|
303
|
-
return new SemVer(version, options)
|
312
|
+
if (!(this instanceof SemVer)) {
|
313
|
+
return new SemVer(version, options)
|
314
|
+
}
|
304
315
|
|
305
|
-
debug('SemVer', version, options)
|
306
|
-
this.options = options
|
307
|
-
this.loose = !!options.loose
|
316
|
+
debug('SemVer', version, options)
|
317
|
+
this.options = options
|
318
|
+
this.loose = !!options.loose
|
308
319
|
|
309
|
-
var m = version.trim().match(options.loose ? re[LOOSE] : re[FULL])
|
320
|
+
var m = version.trim().match(options.loose ? re[LOOSE] : re[FULL])
|
310
321
|
|
311
|
-
if (!m)
|
312
|
-
throw new TypeError('Invalid Version: ' + version)
|
322
|
+
if (!m) {
|
323
|
+
throw new TypeError('Invalid Version: ' + version)
|
324
|
+
}
|
313
325
|
|
314
|
-
this.raw = version
|
326
|
+
this.raw = version
|
315
327
|
|
316
328
|
// these are actually numbers
|
317
|
-
this.major = +m[1]
|
318
|
-
this.minor = +m[2]
|
319
|
-
this.patch = +m[3]
|
329
|
+
this.major = +m[1]
|
330
|
+
this.minor = +m[2]
|
331
|
+
this.patch = +m[3]
|
320
332
|
|
321
|
-
if (this.major > MAX_SAFE_INTEGER || this.major < 0)
|
333
|
+
if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
|
322
334
|
throw new TypeError('Invalid major version')
|
335
|
+
}
|
323
336
|
|
324
|
-
if (this.minor > MAX_SAFE_INTEGER || this.minor < 0)
|
337
|
+
if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
|
325
338
|
throw new TypeError('Invalid minor version')
|
339
|
+
}
|
326
340
|
|
327
|
-
if (this.patch > MAX_SAFE_INTEGER || this.patch < 0)
|
341
|
+
if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
|
328
342
|
throw new TypeError('Invalid patch version')
|
343
|
+
}
|
329
344
|
|
330
345
|
// numberify any prerelease numeric ids
|
331
|
-
if (!m[4])
|
332
|
-
this.prerelease = []
|
333
|
-
else
|
334
|
-
this.prerelease = m[4].split('.').map(function(id) {
|
346
|
+
if (!m[4]) {
|
347
|
+
this.prerelease = []
|
348
|
+
} else {
|
349
|
+
this.prerelease = m[4].split('.').map(function (id) {
|
335
350
|
if (/^[0-9]+$/.test(id)) {
|
336
|
-
var num = +id
|
337
|
-
if (num >= 0 && num < MAX_SAFE_INTEGER)
|
338
|
-
return num
|
351
|
+
var num = +id
|
352
|
+
if (num >= 0 && num < MAX_SAFE_INTEGER) {
|
353
|
+
return num
|
354
|
+
}
|
339
355
|
}
|
340
|
-
return id
|
341
|
-
})
|
356
|
+
return id
|
357
|
+
})
|
358
|
+
}
|
342
359
|
|
343
|
-
this.build = m[5] ? m[5].split('.') : []
|
344
|
-
this.format()
|
360
|
+
this.build = m[5] ? m[5].split('.') : []
|
361
|
+
this.format()
|
345
362
|
}
|
346
363
|
|
347
|
-
SemVer.prototype.format = function() {
|
348
|
-
this.version = this.major + '.' + this.minor + '.' + this.patch
|
349
|
-
if (this.prerelease.length)
|
350
|
-
this.version += '-' + this.prerelease.join('.')
|
351
|
-
|
352
|
-
|
364
|
+
SemVer.prototype.format = function () {
|
365
|
+
this.version = this.major + '.' + this.minor + '.' + this.patch
|
366
|
+
if (this.prerelease.length) {
|
367
|
+
this.version += '-' + this.prerelease.join('.')
|
368
|
+
}
|
369
|
+
return this.version
|
370
|
+
}
|
353
371
|
|
354
|
-
SemVer.prototype.toString = function() {
|
355
|
-
return this.version
|
356
|
-
}
|
372
|
+
SemVer.prototype.toString = function () {
|
373
|
+
return this.version
|
374
|
+
}
|
357
375
|
|
358
|
-
SemVer.prototype.compare = function(other) {
|
359
|
-
debug('SemVer.compare', this.version, this.options, other)
|
360
|
-
if (!(other instanceof SemVer))
|
361
|
-
other = new SemVer(other, this.options)
|
376
|
+
SemVer.prototype.compare = function (other) {
|
377
|
+
debug('SemVer.compare', this.version, this.options, other)
|
378
|
+
if (!(other instanceof SemVer)) {
|
379
|
+
other = new SemVer(other, this.options)
|
380
|
+
}
|
362
381
|
|
363
|
-
return this.compareMain(other) || this.comparePre(other)
|
364
|
-
}
|
382
|
+
return this.compareMain(other) || this.comparePre(other)
|
383
|
+
}
|
365
384
|
|
366
|
-
SemVer.prototype.compareMain = function(other) {
|
367
|
-
if (!(other instanceof SemVer))
|
368
|
-
other = new SemVer(other, this.options)
|
385
|
+
SemVer.prototype.compareMain = function (other) {
|
386
|
+
if (!(other instanceof SemVer)) {
|
387
|
+
other = new SemVer(other, this.options)
|
388
|
+
}
|
369
389
|
|
370
390
|
return compareIdentifiers(this.major, other.major) ||
|
371
391
|
compareIdentifiers(this.minor, other.minor) ||
|
372
|
-
compareIdentifiers(this.patch, other.patch)
|
373
|
-
}
|
392
|
+
compareIdentifiers(this.patch, other.patch)
|
393
|
+
}
|
374
394
|
|
375
|
-
SemVer.prototype.comparePre = function(other) {
|
376
|
-
if (!(other instanceof SemVer))
|
377
|
-
other = new SemVer(other, this.options)
|
395
|
+
SemVer.prototype.comparePre = function (other) {
|
396
|
+
if (!(other instanceof SemVer)) {
|
397
|
+
other = new SemVer(other, this.options)
|
398
|
+
}
|
378
399
|
|
379
400
|
// NOT having a prerelease is > having one
|
380
|
-
if (this.prerelease.length && !other.prerelease.length)
|
381
|
-
return -1
|
382
|
-
else if (!this.prerelease.length && other.prerelease.length)
|
383
|
-
return 1
|
384
|
-
else if (!this.prerelease.length && !other.prerelease.length)
|
385
|
-
return 0
|
386
|
-
|
387
|
-
|
401
|
+
if (this.prerelease.length && !other.prerelease.length) {
|
402
|
+
return -1
|
403
|
+
} else if (!this.prerelease.length && other.prerelease.length) {
|
404
|
+
return 1
|
405
|
+
} else if (!this.prerelease.length && !other.prerelease.length) {
|
406
|
+
return 0
|
407
|
+
}
|
408
|
+
|
409
|
+
var i = 0
|
388
410
|
do {
|
389
|
-
var a = this.prerelease[i]
|
390
|
-
var b = other.prerelease[i]
|
391
|
-
debug('prerelease compare', i, a, b)
|
392
|
-
if (a === undefined && b === undefined)
|
393
|
-
return 0
|
394
|
-
else if (b === undefined)
|
395
|
-
return 1
|
396
|
-
else if (a === undefined)
|
397
|
-
return -1
|
398
|
-
else if (a === b)
|
399
|
-
continue
|
400
|
-
else
|
401
|
-
return compareIdentifiers(a, b)
|
402
|
-
|
403
|
-
}
|
411
|
+
var a = this.prerelease[i]
|
412
|
+
var b = other.prerelease[i]
|
413
|
+
debug('prerelease compare', i, a, b)
|
414
|
+
if (a === undefined && b === undefined) {
|
415
|
+
return 0
|
416
|
+
} else if (b === undefined) {
|
417
|
+
return 1
|
418
|
+
} else if (a === undefined) {
|
419
|
+
return -1
|
420
|
+
} else if (a === b) {
|
421
|
+
continue
|
422
|
+
} else {
|
423
|
+
return compareIdentifiers(a, b)
|
424
|
+
}
|
425
|
+
} while (++i)
|
426
|
+
}
|
404
427
|
|
405
428
|
// preminor will bump the version up to the next minor release, and immediately
|
406
429
|
// down to pre-release. premajor and prepatch work the same way.
|
407
|
-
SemVer.prototype.inc = function(release, identifier) {
|
430
|
+
SemVer.prototype.inc = function (release, identifier) {
|
408
431
|
switch (release) {
|
409
432
|
case 'premajor':
|
410
|
-
this.prerelease.length = 0
|
411
|
-
this.patch = 0
|
412
|
-
this.minor = 0
|
413
|
-
this.major
|
414
|
-
this.inc('pre', identifier)
|
415
|
-
break
|
433
|
+
this.prerelease.length = 0
|
434
|
+
this.patch = 0
|
435
|
+
this.minor = 0
|
436
|
+
this.major++
|
437
|
+
this.inc('pre', identifier)
|
438
|
+
break
|
416
439
|
case 'preminor':
|
417
|
-
this.prerelease.length = 0
|
418
|
-
this.patch = 0
|
419
|
-
this.minor
|
420
|
-
this.inc('pre', identifier)
|
421
|
-
break
|
440
|
+
this.prerelease.length = 0
|
441
|
+
this.patch = 0
|
442
|
+
this.minor++
|
443
|
+
this.inc('pre', identifier)
|
444
|
+
break
|
422
445
|
case 'prepatch':
|
423
446
|
// If this is already a prerelease, it will bump to the next version
|
424
447
|
// drop any prereleases that might already exist, since they are not
|
425
448
|
// relevant at this point.
|
426
|
-
this.prerelease.length = 0
|
427
|
-
this.inc('patch', identifier)
|
428
|
-
this.inc('pre', identifier)
|
429
|
-
break
|
449
|
+
this.prerelease.length = 0
|
450
|
+
this.inc('patch', identifier)
|
451
|
+
this.inc('pre', identifier)
|
452
|
+
break
|
430
453
|
// If the input is a non-prerelease version, this acts the same as
|
431
454
|
// prepatch.
|
432
455
|
case 'prerelease':
|
433
|
-
if (this.prerelease.length === 0)
|
434
|
-
this.inc('patch', identifier)
|
435
|
-
|
436
|
-
|
456
|
+
if (this.prerelease.length === 0) {
|
457
|
+
this.inc('patch', identifier)
|
458
|
+
}
|
459
|
+
this.inc('pre', identifier)
|
460
|
+
break
|
437
461
|
|
438
462
|
case 'major':
|
439
463
|
// If this is a pre-major version, bump up to the same major version.
|
440
464
|
// Otherwise increment major.
|
441
465
|
// 1.0.0-5 bumps to 1.0.0
|
442
466
|
// 1.1.0 bumps to 2.0.0
|
443
|
-
if (this.minor !== 0 ||
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
467
|
+
if (this.minor !== 0 ||
|
468
|
+
this.patch !== 0 ||
|
469
|
+
this.prerelease.length === 0) {
|
470
|
+
this.major++
|
471
|
+
}
|
472
|
+
this.minor = 0
|
473
|
+
this.patch = 0
|
474
|
+
this.prerelease = []
|
475
|
+
break
|
449
476
|
case 'minor':
|
450
477
|
// If this is a pre-minor version, bump up to the same minor version.
|
451
478
|
// Otherwise increment minor.
|
452
479
|
// 1.2.0-5 bumps to 1.2.0
|
453
480
|
// 1.2.1 bumps to 1.3.0
|
454
|
-
if (this.patch !== 0 || this.prerelease.length === 0)
|
455
|
-
this.minor
|
456
|
-
|
457
|
-
this.
|
458
|
-
|
481
|
+
if (this.patch !== 0 || this.prerelease.length === 0) {
|
482
|
+
this.minor++
|
483
|
+
}
|
484
|
+
this.patch = 0
|
485
|
+
this.prerelease = []
|
486
|
+
break
|
459
487
|
case 'patch':
|
460
488
|
// If this is not a pre-release version, it will increment the patch.
|
461
489
|
// If it is a pre-release it will bump up to the same patch version.
|
462
490
|
// 1.2.0-5 patches to 1.2.0
|
463
491
|
// 1.2.0 patches to 1.2.1
|
464
|
-
if (this.prerelease.length === 0)
|
465
|
-
this.patch
|
466
|
-
|
467
|
-
|
492
|
+
if (this.prerelease.length === 0) {
|
493
|
+
this.patch++
|
494
|
+
}
|
495
|
+
this.prerelease = []
|
496
|
+
break
|
468
497
|
// This probably shouldn't be used publicly.
|
469
498
|
// 1.0.0 "pre" would become 1.0.0-0 which is the wrong direction.
|
470
499
|
case 'pre':
|
471
|
-
if (this.prerelease.length === 0)
|
472
|
-
this.prerelease = [0]
|
473
|
-
else {
|
474
|
-
var i = this.prerelease.length
|
500
|
+
if (this.prerelease.length === 0) {
|
501
|
+
this.prerelease = [0]
|
502
|
+
} else {
|
503
|
+
var i = this.prerelease.length
|
475
504
|
while (--i >= 0) {
|
476
505
|
if (typeof this.prerelease[i] === 'number') {
|
477
|
-
this.prerelease[i]
|
478
|
-
i = -2
|
506
|
+
this.prerelease[i]++
|
507
|
+
i = -2
|
479
508
|
}
|
480
509
|
}
|
481
|
-
if (i === -1)
|
482
|
-
|
510
|
+
if (i === -1) {
|
511
|
+
// didn't increment anything
|
512
|
+
this.prerelease.push(0)
|
513
|
+
}
|
483
514
|
}
|
484
515
|
if (identifier) {
|
485
516
|
// 1.2.0-beta.1 bumps to 1.2.0-beta.2,
|
486
517
|
// 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
|
487
518
|
if (this.prerelease[0] === identifier) {
|
488
|
-
if (isNaN(this.prerelease[1]))
|
489
|
-
this.prerelease = [identifier, 0]
|
490
|
-
|
491
|
-
|
519
|
+
if (isNaN(this.prerelease[1])) {
|
520
|
+
this.prerelease = [identifier, 0]
|
521
|
+
}
|
522
|
+
} else {
|
523
|
+
this.prerelease = [identifier, 0]
|
524
|
+
}
|
492
525
|
}
|
493
|
-
break
|
526
|
+
break
|
494
527
|
|
495
528
|
default:
|
496
|
-
throw new Error('invalid increment argument: ' + release)
|
529
|
+
throw new Error('invalid increment argument: ' + release)
|
497
530
|
}
|
498
|
-
this.format()
|
499
|
-
this.raw = this.version
|
500
|
-
return this
|
501
|
-
}
|
531
|
+
this.format()
|
532
|
+
this.raw = this.version
|
533
|
+
return this
|
534
|
+
}
|
502
535
|
|
503
|
-
exports.inc = inc
|
504
|
-
function inc(version, release, loose, identifier) {
|
505
|
-
if (typeof(loose) === 'string') {
|
506
|
-
identifier = loose
|
507
|
-
loose = undefined
|
536
|
+
exports.inc = inc
|
537
|
+
function inc (version, release, loose, identifier) {
|
538
|
+
if (typeof (loose) === 'string') {
|
539
|
+
identifier = loose
|
540
|
+
loose = undefined
|
508
541
|
}
|
509
542
|
|
510
543
|
try {
|
511
|
-
return new SemVer(version, loose).inc(release, identifier).version
|
544
|
+
return new SemVer(version, loose).inc(release, identifier).version
|
512
545
|
} catch (er) {
|
513
|
-
return null
|
546
|
+
return null
|
514
547
|
}
|
515
548
|
}
|
516
549
|
|
517
|
-
exports.diff = diff
|
518
|
-
function diff(version1, version2) {
|
550
|
+
exports.diff = diff
|
551
|
+
function diff (version1, version2) {
|
519
552
|
if (eq(version1, version2)) {
|
520
|
-
return null
|
553
|
+
return null
|
521
554
|
} else {
|
522
|
-
var v1 = parse(version1)
|
523
|
-
var v2 = parse(version2)
|
555
|
+
var v1 = parse(version1)
|
556
|
+
var v2 = parse(version2)
|
557
|
+
var prefix = ''
|
524
558
|
if (v1.prerelease.length || v2.prerelease.length) {
|
525
|
-
|
526
|
-
|
527
|
-
if (v1[key] !== v2[key]) {
|
528
|
-
return 'pre'+key;
|
529
|
-
}
|
530
|
-
}
|
531
|
-
}
|
532
|
-
return 'prerelease';
|
559
|
+
prefix = 'pre'
|
560
|
+
var defaultResult = 'prerelease'
|
533
561
|
}
|
534
562
|
for (var key in v1) {
|
535
563
|
if (key === 'major' || key === 'minor' || key === 'patch') {
|
536
564
|
if (v1[key] !== v2[key]) {
|
537
|
-
return key
|
565
|
+
return prefix + key
|
538
566
|
}
|
539
567
|
}
|
540
568
|
}
|
569
|
+
return defaultResult // may be undefined
|
541
570
|
}
|
542
571
|
}
|
543
572
|
|
544
|
-
exports.compareIdentifiers = compareIdentifiers
|
573
|
+
exports.compareIdentifiers = compareIdentifiers
|
545
574
|
|
546
|
-
var numeric = /^[0-9]
|
547
|
-
function compareIdentifiers(a, b) {
|
548
|
-
var anum = numeric.test(a)
|
549
|
-
var bnum = numeric.test(b)
|
575
|
+
var numeric = /^[0-9]+$/
|
576
|
+
function compareIdentifiers (a, b) {
|
577
|
+
var anum = numeric.test(a)
|
578
|
+
var bnum = numeric.test(b)
|
550
579
|
|
551
580
|
if (anum && bnum) {
|
552
|
-
a = +a
|
553
|
-
b = +b
|
581
|
+
a = +a
|
582
|
+
b = +b
|
554
583
|
}
|
555
584
|
|
556
|
-
return
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
585
|
+
return a === b ? 0
|
586
|
+
: (anum && !bnum) ? -1
|
587
|
+
: (bnum && !anum) ? 1
|
588
|
+
: a < b ? -1
|
589
|
+
: 1
|
561
590
|
}
|
562
591
|
|
563
|
-
exports.rcompareIdentifiers = rcompareIdentifiers
|
564
|
-
function rcompareIdentifiers(a, b) {
|
565
|
-
return compareIdentifiers(b, a)
|
592
|
+
exports.rcompareIdentifiers = rcompareIdentifiers
|
593
|
+
function rcompareIdentifiers (a, b) {
|
594
|
+
return compareIdentifiers(b, a)
|
566
595
|
}
|
567
596
|
|
568
|
-
exports.major = major
|
569
|
-
function major(a, loose) {
|
570
|
-
return new SemVer(a, loose).major
|
597
|
+
exports.major = major
|
598
|
+
function major (a, loose) {
|
599
|
+
return new SemVer(a, loose).major
|
571
600
|
}
|
572
601
|
|
573
|
-
exports.minor = minor
|
574
|
-
function minor(a, loose) {
|
575
|
-
return new SemVer(a, loose).minor
|
602
|
+
exports.minor = minor
|
603
|
+
function minor (a, loose) {
|
604
|
+
return new SemVer(a, loose).minor
|
576
605
|
}
|
577
606
|
|
578
|
-
exports.patch = patch
|
579
|
-
function patch(a, loose) {
|
580
|
-
return new SemVer(a, loose).patch
|
607
|
+
exports.patch = patch
|
608
|
+
function patch (a, loose) {
|
609
|
+
return new SemVer(a, loose).patch
|
581
610
|
}
|
582
611
|
|
583
|
-
exports.compare = compare
|
584
|
-
function compare(a, b, loose) {
|
585
|
-
return new SemVer(a, loose).compare(new SemVer(b, loose))
|
612
|
+
exports.compare = compare
|
613
|
+
function compare (a, b, loose) {
|
614
|
+
return new SemVer(a, loose).compare(new SemVer(b, loose))
|
586
615
|
}
|
587
616
|
|
588
|
-
exports.compareLoose = compareLoose
|
589
|
-
function compareLoose(a, b) {
|
590
|
-
return compare(a, b, true)
|
617
|
+
exports.compareLoose = compareLoose
|
618
|
+
function compareLoose (a, b) {
|
619
|
+
return compare(a, b, true)
|
591
620
|
}
|
592
621
|
|
593
|
-
exports.rcompare = rcompare
|
594
|
-
function rcompare(a, b, loose) {
|
595
|
-
return compare(b, a, loose)
|
622
|
+
exports.rcompare = rcompare
|
623
|
+
function rcompare (a, b, loose) {
|
624
|
+
return compare(b, a, loose)
|
596
625
|
}
|
597
626
|
|
598
|
-
exports.sort = sort
|
599
|
-
function sort(list, loose) {
|
600
|
-
return list.sort(function(a, b) {
|
601
|
-
return exports.compare(a, b, loose)
|
602
|
-
})
|
627
|
+
exports.sort = sort
|
628
|
+
function sort (list, loose) {
|
629
|
+
return list.sort(function (a, b) {
|
630
|
+
return exports.compare(a, b, loose)
|
631
|
+
})
|
603
632
|
}
|
604
633
|
|
605
|
-
exports.rsort = rsort
|
606
|
-
function rsort(list, loose) {
|
607
|
-
return list.sort(function(a, b) {
|
608
|
-
return exports.rcompare(a, b, loose)
|
609
|
-
})
|
634
|
+
exports.rsort = rsort
|
635
|
+
function rsort (list, loose) {
|
636
|
+
return list.sort(function (a, b) {
|
637
|
+
return exports.rcompare(a, b, loose)
|
638
|
+
})
|
610
639
|
}
|
611
640
|
|
612
|
-
exports.gt = gt
|
613
|
-
function gt(a, b, loose) {
|
614
|
-
return compare(a, b, loose) > 0
|
641
|
+
exports.gt = gt
|
642
|
+
function gt (a, b, loose) {
|
643
|
+
return compare(a, b, loose) > 0
|
615
644
|
}
|
616
645
|
|
617
|
-
exports.lt = lt
|
618
|
-
function lt(a, b, loose) {
|
619
|
-
return compare(a, b, loose) < 0
|
646
|
+
exports.lt = lt
|
647
|
+
function lt (a, b, loose) {
|
648
|
+
return compare(a, b, loose) < 0
|
620
649
|
}
|
621
650
|
|
622
|
-
exports.eq = eq
|
623
|
-
function eq(a, b, loose) {
|
624
|
-
return compare(a, b, loose) === 0
|
651
|
+
exports.eq = eq
|
652
|
+
function eq (a, b, loose) {
|
653
|
+
return compare(a, b, loose) === 0
|
625
654
|
}
|
626
655
|
|
627
|
-
exports.neq = neq
|
628
|
-
function neq(a, b, loose) {
|
629
|
-
return compare(a, b, loose) !== 0
|
656
|
+
exports.neq = neq
|
657
|
+
function neq (a, b, loose) {
|
658
|
+
return compare(a, b, loose) !== 0
|
630
659
|
}
|
631
660
|
|
632
|
-
exports.gte = gte
|
633
|
-
function gte(a, b, loose) {
|
634
|
-
return compare(a, b, loose) >= 0
|
661
|
+
exports.gte = gte
|
662
|
+
function gte (a, b, loose) {
|
663
|
+
return compare(a, b, loose) >= 0
|
635
664
|
}
|
636
665
|
|
637
|
-
exports.lte = lte
|
638
|
-
function lte(a, b, loose) {
|
639
|
-
return compare(a, b, loose) <= 0
|
666
|
+
exports.lte = lte
|
667
|
+
function lte (a, b, loose) {
|
668
|
+
return compare(a, b, loose) <= 0
|
640
669
|
}
|
641
670
|
|
642
|
-
exports.cmp = cmp
|
643
|
-
function cmp(a, op, b, loose) {
|
644
|
-
var ret;
|
671
|
+
exports.cmp = cmp
|
672
|
+
function cmp (a, op, b, loose) {
|
645
673
|
switch (op) {
|
646
674
|
case '===':
|
647
|
-
if (typeof a === 'object')
|
648
|
-
|
649
|
-
|
650
|
-
|
675
|
+
if (typeof a === 'object')
|
676
|
+
a = a.version
|
677
|
+
if (typeof b === 'object')
|
678
|
+
b = b.version
|
679
|
+
return a === b
|
680
|
+
|
651
681
|
case '!==':
|
652
|
-
if (typeof a === 'object')
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
case '
|
659
|
-
case '
|
660
|
-
case '
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
682
|
+
if (typeof a === 'object')
|
683
|
+
a = a.version
|
684
|
+
if (typeof b === 'object')
|
685
|
+
b = b.version
|
686
|
+
return a !== b
|
687
|
+
|
688
|
+
case '':
|
689
|
+
case '=':
|
690
|
+
case '==':
|
691
|
+
return eq(a, b, loose)
|
692
|
+
|
693
|
+
case '!=':
|
694
|
+
return neq(a, b, loose)
|
695
|
+
|
696
|
+
case '>':
|
697
|
+
return gt(a, b, loose)
|
698
|
+
|
699
|
+
case '>=':
|
700
|
+
return gte(a, b, loose)
|
701
|
+
|
702
|
+
case '<':
|
703
|
+
return lt(a, b, loose)
|
704
|
+
|
705
|
+
case '<=':
|
706
|
+
return lte(a, b, loose)
|
707
|
+
|
708
|
+
default:
|
709
|
+
throw new TypeError('Invalid operator: ' + op)
|
710
|
+
}
|
711
|
+
}
|
712
|
+
|
713
|
+
exports.Comparator = Comparator
|
714
|
+
function Comparator (comp, options) {
|
715
|
+
if (!options || typeof options !== 'object') {
|
716
|
+
options = {
|
717
|
+
loose: !!options,
|
718
|
+
includePrerelease: false
|
719
|
+
}
|
720
|
+
}
|
671
721
|
|
672
722
|
if (comp instanceof Comparator) {
|
673
|
-
if (comp.loose === !!options.loose)
|
674
|
-
return comp
|
675
|
-
else
|
676
|
-
comp = comp.value
|
723
|
+
if (comp.loose === !!options.loose) {
|
724
|
+
return comp
|
725
|
+
} else {
|
726
|
+
comp = comp.value
|
727
|
+
}
|
677
728
|
}
|
678
729
|
|
679
|
-
if (!(this instanceof Comparator))
|
680
|
-
return new Comparator(comp, options)
|
730
|
+
if (!(this instanceof Comparator)) {
|
731
|
+
return new Comparator(comp, options)
|
732
|
+
}
|
681
733
|
|
682
|
-
debug('comparator', comp, options)
|
683
|
-
this.options = options
|
684
|
-
this.loose = !!options.loose
|
685
|
-
this.parse(comp)
|
734
|
+
debug('comparator', comp, options)
|
735
|
+
this.options = options
|
736
|
+
this.loose = !!options.loose
|
737
|
+
this.parse(comp)
|
686
738
|
|
687
|
-
if (this.semver === ANY)
|
688
|
-
this.value = ''
|
689
|
-
else
|
690
|
-
this.value = this.operator + this.semver.version
|
739
|
+
if (this.semver === ANY) {
|
740
|
+
this.value = ''
|
741
|
+
} else {
|
742
|
+
this.value = this.operator + this.semver.version
|
743
|
+
}
|
691
744
|
|
692
|
-
debug('comp', this)
|
745
|
+
debug('comp', this)
|
693
746
|
}
|
694
747
|
|
695
|
-
var ANY = {}
|
696
|
-
Comparator.prototype.parse = function(comp) {
|
697
|
-
var r = this.options.loose ? re[COMPARATORLOOSE] : re[COMPARATOR]
|
698
|
-
var m = comp.match(r)
|
748
|
+
var ANY = {}
|
749
|
+
Comparator.prototype.parse = function (comp) {
|
750
|
+
var r = this.options.loose ? re[COMPARATORLOOSE] : re[COMPARATOR]
|
751
|
+
var m = comp.match(r)
|
699
752
|
|
700
|
-
if (!m)
|
701
|
-
throw new TypeError('Invalid comparator: ' + comp)
|
753
|
+
if (!m) {
|
754
|
+
throw new TypeError('Invalid comparator: ' + comp)
|
755
|
+
}
|
702
756
|
|
703
|
-
this.operator = m[1]
|
704
|
-
if (this.operator === '=')
|
705
|
-
this.operator = ''
|
757
|
+
this.operator = m[1]
|
758
|
+
if (this.operator === '=') {
|
759
|
+
this.operator = ''
|
760
|
+
}
|
706
761
|
|
707
762
|
// if it literally is just '>' or '' then allow anything.
|
708
|
-
if (!m[2])
|
709
|
-
this.semver = ANY
|
710
|
-
else
|
711
|
-
this.semver = new SemVer(m[2], this.options.loose)
|
712
|
-
}
|
763
|
+
if (!m[2]) {
|
764
|
+
this.semver = ANY
|
765
|
+
} else {
|
766
|
+
this.semver = new SemVer(m[2], this.options.loose)
|
767
|
+
}
|
768
|
+
}
|
713
769
|
|
714
|
-
Comparator.prototype.toString = function() {
|
715
|
-
return this.value
|
716
|
-
}
|
770
|
+
Comparator.prototype.toString = function () {
|
771
|
+
return this.value
|
772
|
+
}
|
717
773
|
|
718
|
-
Comparator.prototype.test = function(version) {
|
719
|
-
debug('Comparator.test', version, this.options.loose)
|
774
|
+
Comparator.prototype.test = function (version) {
|
775
|
+
debug('Comparator.test', version, this.options.loose)
|
720
776
|
|
721
|
-
if (this.semver === ANY)
|
722
|
-
return true
|
777
|
+
if (this.semver === ANY) {
|
778
|
+
return true
|
779
|
+
}
|
723
780
|
|
724
|
-
if (typeof version === 'string')
|
725
|
-
version = new SemVer(version, this.options)
|
781
|
+
if (typeof version === 'string') {
|
782
|
+
version = new SemVer(version, this.options)
|
783
|
+
}
|
726
784
|
|
727
|
-
return cmp(version, this.operator, this.semver, this.options)
|
728
|
-
}
|
785
|
+
return cmp(version, this.operator, this.semver, this.options)
|
786
|
+
}
|
729
787
|
|
730
|
-
Comparator.prototype.intersects = function(comp, options) {
|
788
|
+
Comparator.prototype.intersects = function (comp, options) {
|
731
789
|
if (!(comp instanceof Comparator)) {
|
732
|
-
throw new TypeError('a Comparator is required')
|
790
|
+
throw new TypeError('a Comparator is required')
|
733
791
|
}
|
734
792
|
|
735
|
-
if (!options || typeof options !== 'object')
|
736
|
-
options = {
|
793
|
+
if (!options || typeof options !== 'object') {
|
794
|
+
options = {
|
795
|
+
loose: !!options,
|
796
|
+
includePrerelease: false
|
797
|
+
}
|
798
|
+
}
|
737
799
|
|
738
|
-
var rangeTmp
|
800
|
+
var rangeTmp
|
739
801
|
|
740
802
|
if (this.operator === '') {
|
741
|
-
rangeTmp = new Range(comp.value, options)
|
742
|
-
return satisfies(this.value, rangeTmp, options)
|
803
|
+
rangeTmp = new Range(comp.value, options)
|
804
|
+
return satisfies(this.value, rangeTmp, options)
|
743
805
|
} else if (comp.operator === '') {
|
744
|
-
rangeTmp = new Range(this.value, options)
|
745
|
-
return satisfies(comp.semver, rangeTmp, options)
|
806
|
+
rangeTmp = new Range(this.value, options)
|
807
|
+
return satisfies(comp.semver, rangeTmp, options)
|
746
808
|
}
|
747
809
|
|
748
810
|
var sameDirectionIncreasing =
|
749
811
|
(this.operator === '>=' || this.operator === '>') &&
|
750
|
-
(comp.operator === '>=' || comp.operator === '>')
|
812
|
+
(comp.operator === '>=' || comp.operator === '>')
|
751
813
|
var sameDirectionDecreasing =
|
752
814
|
(this.operator === '<=' || this.operator === '<') &&
|
753
|
-
(comp.operator === '<=' || comp.operator === '<')
|
754
|
-
var sameSemVer = this.semver.version === comp.semver.version
|
815
|
+
(comp.operator === '<=' || comp.operator === '<')
|
816
|
+
var sameSemVer = this.semver.version === comp.semver.version
|
755
817
|
var differentDirectionsInclusive =
|
756
818
|
(this.operator === '>=' || this.operator === '<=') &&
|
757
|
-
(comp.operator === '>=' || comp.operator === '<=')
|
819
|
+
(comp.operator === '>=' || comp.operator === '<=')
|
758
820
|
var oppositeDirectionsLessThan =
|
759
821
|
cmp(this.semver, '<', comp.semver, options) &&
|
760
822
|
((this.operator === '>=' || this.operator === '>') &&
|
761
|
-
(comp.operator === '<=' || comp.operator === '<'))
|
823
|
+
(comp.operator === '<=' || comp.operator === '<'))
|
762
824
|
var oppositeDirectionsGreaterThan =
|
763
825
|
cmp(this.semver, '>', comp.semver, options) &&
|
764
826
|
((this.operator === '<=' || this.operator === '<') &&
|
765
|
-
(comp.operator === '>=' || comp.operator === '>'))
|
827
|
+
(comp.operator === '>=' || comp.operator === '>'))
|
766
828
|
|
767
829
|
return sameDirectionIncreasing || sameDirectionDecreasing ||
|
768
830
|
(sameSemVer && differentDirectionsInclusive) ||
|
769
|
-
oppositeDirectionsLessThan || oppositeDirectionsGreaterThan
|
770
|
-
}
|
771
|
-
|
831
|
+
oppositeDirectionsLessThan || oppositeDirectionsGreaterThan
|
832
|
+
}
|
772
833
|
|
773
|
-
exports.Range = Range
|
774
|
-
function Range(range, options) {
|
775
|
-
if (!options || typeof options !== 'object')
|
776
|
-
options = {
|
834
|
+
exports.Range = Range
|
835
|
+
function Range (range, options) {
|
836
|
+
if (!options || typeof options !== 'object') {
|
837
|
+
options = {
|
838
|
+
loose: !!options,
|
839
|
+
includePrerelease: false
|
840
|
+
}
|
841
|
+
}
|
777
842
|
|
778
843
|
if (range instanceof Range) {
|
779
844
|
if (range.loose === !!options.loose &&
|
780
845
|
range.includePrerelease === !!options.includePrerelease) {
|
781
|
-
return range
|
846
|
+
return range
|
782
847
|
} else {
|
783
|
-
return new Range(range.raw, options)
|
848
|
+
return new Range(range.raw, options)
|
784
849
|
}
|
785
850
|
}
|
786
851
|
|
787
852
|
if (range instanceof Comparator) {
|
788
|
-
return new Range(range.value, options)
|
853
|
+
return new Range(range.value, options)
|
789
854
|
}
|
790
855
|
|
791
|
-
if (!(this instanceof Range))
|
792
|
-
return new Range(range, options)
|
856
|
+
if (!(this instanceof Range)) {
|
857
|
+
return new Range(range, options)
|
858
|
+
}
|
793
859
|
|
794
|
-
this.options = options
|
795
|
-
this.loose = !!options.loose
|
860
|
+
this.options = options
|
861
|
+
this.loose = !!options.loose
|
796
862
|
this.includePrerelease = !!options.includePrerelease
|
797
863
|
|
798
864
|
// First, split based on boolean or ||
|
799
|
-
this.raw = range
|
800
|
-
this.set = range.split(/\s*\|\|\s*/).map(function(range) {
|
801
|
-
return this.parseRange(range.trim())
|
802
|
-
}, this).filter(function(c) {
|
865
|
+
this.raw = range
|
866
|
+
this.set = range.split(/\s*\|\|\s*/).map(function (range) {
|
867
|
+
return this.parseRange(range.trim())
|
868
|
+
}, this).filter(function (c) {
|
803
869
|
// throw out any that are not relevant for whatever reason
|
804
|
-
return c.length
|
805
|
-
})
|
870
|
+
return c.length
|
871
|
+
})
|
806
872
|
|
807
873
|
if (!this.set.length) {
|
808
|
-
throw new TypeError('Invalid SemVer Range: ' + range)
|
874
|
+
throw new TypeError('Invalid SemVer Range: ' + range)
|
809
875
|
}
|
810
876
|
|
811
|
-
this.format()
|
877
|
+
this.format()
|
812
878
|
}
|
813
879
|
|
814
|
-
Range.prototype.format = function() {
|
815
|
-
this.range = this.set.map(function(comps) {
|
816
|
-
return comps.join(' ').trim()
|
817
|
-
}).join('||').trim()
|
818
|
-
return this.range
|
819
|
-
}
|
880
|
+
Range.prototype.format = function () {
|
881
|
+
this.range = this.set.map(function (comps) {
|
882
|
+
return comps.join(' ').trim()
|
883
|
+
}).join('||').trim()
|
884
|
+
return this.range
|
885
|
+
}
|
820
886
|
|
821
|
-
Range.prototype.toString = function() {
|
822
|
-
return this.range
|
823
|
-
}
|
887
|
+
Range.prototype.toString = function () {
|
888
|
+
return this.range
|
889
|
+
}
|
824
890
|
|
825
|
-
Range.prototype.parseRange = function(range) {
|
826
|
-
var loose = this.options.loose
|
827
|
-
range = range.trim()
|
891
|
+
Range.prototype.parseRange = function (range) {
|
892
|
+
var loose = this.options.loose
|
893
|
+
range = range.trim()
|
828
894
|
// `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
|
829
|
-
var hr = loose ? re[HYPHENRANGELOOSE] : re[HYPHENRANGE]
|
830
|
-
range = range.replace(hr, hyphenReplace)
|
831
|
-
debug('hyphen replace', range)
|
895
|
+
var hr = loose ? re[HYPHENRANGELOOSE] : re[HYPHENRANGE]
|
896
|
+
range = range.replace(hr, hyphenReplace)
|
897
|
+
debug('hyphen replace', range)
|
832
898
|
// `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
|
833
|
-
range = range.replace(re[COMPARATORTRIM], comparatorTrimReplace)
|
834
|
-
debug('comparator trim', range, re[COMPARATORTRIM])
|
899
|
+
range = range.replace(re[COMPARATORTRIM], comparatorTrimReplace)
|
900
|
+
debug('comparator trim', range, re[COMPARATORTRIM])
|
835
901
|
|
836
902
|
// `~ 1.2.3` => `~1.2.3`
|
837
|
-
range = range.replace(re[TILDETRIM], tildeTrimReplace)
|
903
|
+
range = range.replace(re[TILDETRIM], tildeTrimReplace)
|
838
904
|
|
839
905
|
// `^ 1.2.3` => `^1.2.3`
|
840
|
-
range = range.replace(re[CARETTRIM], caretTrimReplace)
|
906
|
+
range = range.replace(re[CARETTRIM], caretTrimReplace)
|
841
907
|
|
842
908
|
// normalize spaces
|
843
|
-
range = range.split(/\s+/).join(' ')
|
909
|
+
range = range.split(/\s+/).join(' ')
|
844
910
|
|
845
911
|
// At this point, the range is completely trimmed and
|
846
912
|
// ready to be split into comparators.
|
847
913
|
|
848
|
-
var compRe = loose ? re[COMPARATORLOOSE] : re[COMPARATOR]
|
849
|
-
var set = range.split(' ').map(function(comp) {
|
850
|
-
return parseComparator(comp, this.options)
|
851
|
-
}, this).join(' ').split(/\s+/)
|
914
|
+
var compRe = loose ? re[COMPARATORLOOSE] : re[COMPARATOR]
|
915
|
+
var set = range.split(' ').map(function (comp) {
|
916
|
+
return parseComparator(comp, this.options)
|
917
|
+
}, this).join(' ').split(/\s+/)
|
852
918
|
if (this.options.loose) {
|
853
919
|
// in loose mode, throw out any that are not valid comparators
|
854
|
-
set = set.filter(function(comp) {
|
855
|
-
return !!comp.match(compRe)
|
856
|
-
})
|
920
|
+
set = set.filter(function (comp) {
|
921
|
+
return !!comp.match(compRe)
|
922
|
+
})
|
857
923
|
}
|
858
|
-
set = set.map(function(comp) {
|
859
|
-
return new Comparator(comp, this.options)
|
860
|
-
}, this)
|
924
|
+
set = set.map(function (comp) {
|
925
|
+
return new Comparator(comp, this.options)
|
926
|
+
}, this)
|
861
927
|
|
862
|
-
return set
|
863
|
-
}
|
928
|
+
return set
|
929
|
+
}
|
864
930
|
|
865
|
-
Range.prototype.intersects = function(range, options) {
|
931
|
+
Range.prototype.intersects = function (range, options) {
|
866
932
|
if (!(range instanceof Range)) {
|
867
|
-
throw new TypeError('a Range is required')
|
933
|
+
throw new TypeError('a Range is required')
|
868
934
|
}
|
869
935
|
|
870
|
-
return this.set.some(function(thisComparators) {
|
871
|
-
return thisComparators.every(function(thisComparator) {
|
872
|
-
return range.set.some(function(rangeComparators) {
|
873
|
-
return rangeComparators.every(function(rangeComparator) {
|
874
|
-
return thisComparator.intersects(rangeComparator, options)
|
875
|
-
})
|
876
|
-
})
|
877
|
-
})
|
878
|
-
})
|
879
|
-
}
|
936
|
+
return this.set.some(function (thisComparators) {
|
937
|
+
return thisComparators.every(function (thisComparator) {
|
938
|
+
return range.set.some(function (rangeComparators) {
|
939
|
+
return rangeComparators.every(function (rangeComparator) {
|
940
|
+
return thisComparator.intersects(rangeComparator, options)
|
941
|
+
})
|
942
|
+
})
|
943
|
+
})
|
944
|
+
})
|
945
|
+
}
|
880
946
|
|
881
947
|
// Mostly just for testing and legacy API reasons
|
882
|
-
exports.toComparators = toComparators
|
883
|
-
function toComparators(range, options) {
|
884
|
-
return new Range(range, options).set.map(function(comp) {
|
885
|
-
return comp.map(function(c) {
|
886
|
-
return c.value
|
887
|
-
}).join(' ').trim().split(' ')
|
888
|
-
})
|
948
|
+
exports.toComparators = toComparators
|
949
|
+
function toComparators (range, options) {
|
950
|
+
return new Range(range, options).set.map(function (comp) {
|
951
|
+
return comp.map(function (c) {
|
952
|
+
return c.value
|
953
|
+
}).join(' ').trim().split(' ')
|
954
|
+
})
|
889
955
|
}
|
890
956
|
|
891
957
|
// comprised of xranges, tildes, stars, and gtlt's at this point.
|
892
958
|
// already replaced the hyphen ranges
|
893
959
|
// turn into a set of JUST comparators.
|
894
|
-
function parseComparator(comp, options) {
|
895
|
-
debug('comp', comp, options)
|
896
|
-
comp = replaceCarets(comp, options)
|
897
|
-
debug('caret', comp)
|
898
|
-
comp = replaceTildes(comp, options)
|
899
|
-
debug('tildes', comp)
|
900
|
-
comp = replaceXRanges(comp, options)
|
901
|
-
debug('xrange', comp)
|
902
|
-
comp = replaceStars(comp, options)
|
903
|
-
debug('stars', comp)
|
904
|
-
return comp
|
960
|
+
function parseComparator (comp, options) {
|
961
|
+
debug('comp', comp, options)
|
962
|
+
comp = replaceCarets(comp, options)
|
963
|
+
debug('caret', comp)
|
964
|
+
comp = replaceTildes(comp, options)
|
965
|
+
debug('tildes', comp)
|
966
|
+
comp = replaceXRanges(comp, options)
|
967
|
+
debug('xrange', comp)
|
968
|
+
comp = replaceStars(comp, options)
|
969
|
+
debug('stars', comp)
|
970
|
+
return comp
|
905
971
|
}
|
906
972
|
|
907
|
-
function isX(id) {
|
908
|
-
return !id || id.toLowerCase() === 'x' || id === '*'
|
973
|
+
function isX (id) {
|
974
|
+
return !id || id.toLowerCase() === 'x' || id === '*'
|
909
975
|
}
|
910
976
|
|
911
977
|
// ~, ~> --> * (any, kinda silly)
|
@@ -914,41 +980,38 @@ function isX(id) {
|
|
914
980
|
// ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0
|
915
981
|
// ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0
|
916
982
|
// ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0
|
917
|
-
function replaceTildes(comp, options) {
|
918
|
-
return comp.trim().split(/\s+/).map(function(comp) {
|
919
|
-
return replaceTilde(comp, options)
|
920
|
-
}).join(' ')
|
921
|
-
}
|
922
|
-
|
923
|
-
function replaceTilde(comp, options) {
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
if (isX(
|
932
|
-
ret = ''
|
933
|
-
else if (isX(
|
934
|
-
ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';
|
935
|
-
else if (isX(p))
|
983
|
+
function replaceTildes (comp, options) {
|
984
|
+
return comp.trim().split(/\s+/).map(function (comp) {
|
985
|
+
return replaceTilde(comp, options)
|
986
|
+
}).join(' ')
|
987
|
+
}
|
988
|
+
|
989
|
+
function replaceTilde (comp, options) {
|
990
|
+
var r = options.loose ? re[TILDELOOSE] : re[TILDE]
|
991
|
+
return comp.replace(r, function (_, M, m, p, pr) {
|
992
|
+
debug('tilde', comp, _, M, m, p, pr)
|
993
|
+
var ret
|
994
|
+
|
995
|
+
if (isX(M)) {
|
996
|
+
ret = ''
|
997
|
+
} else if (isX(m)) {
|
998
|
+
ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0'
|
999
|
+
} else if (isX(p)) {
|
936
1000
|
// ~1.2 == >=1.2.0 <1.3.0
|
937
|
-
ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0'
|
938
|
-
else if (pr) {
|
939
|
-
debug('replaceTilde pr', pr)
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
' <' + M + '.' + (+m + 1) + '.0';
|
944
|
-
} else
|
1001
|
+
ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0'
|
1002
|
+
} else if (pr) {
|
1003
|
+
debug('replaceTilde pr', pr)
|
1004
|
+
ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
|
1005
|
+
' <' + M + '.' + (+m + 1) + '.0'
|
1006
|
+
} else {
|
945
1007
|
// ~1.2.3 == >=1.2.3 <1.3.0
|
946
1008
|
ret = '>=' + M + '.' + m + '.' + p +
|
947
|
-
' <' + M + '.' + (+m + 1) + '.0'
|
1009
|
+
' <' + M + '.' + (+m + 1) + '.0'
|
1010
|
+
}
|
948
1011
|
|
949
|
-
debug('tilde return', ret)
|
950
|
-
return ret
|
951
|
-
})
|
1012
|
+
debug('tilde return', ret)
|
1013
|
+
return ret
|
1014
|
+
})
|
952
1015
|
}
|
953
1016
|
|
954
1017
|
// ^ --> * (any, kinda silly)
|
@@ -957,142 +1020,144 @@ function replaceTilde(comp, options) {
|
|
957
1020
|
// ^1.2, ^1.2.x --> >=1.2.0 <2.0.0
|
958
1021
|
// ^1.2.3 --> >=1.2.3 <2.0.0
|
959
1022
|
// ^1.2.0 --> >=1.2.0 <2.0.0
|
960
|
-
function replaceCarets(comp, options) {
|
961
|
-
return comp.trim().split(/\s+/).map(function(comp) {
|
962
|
-
return replaceCaret(comp, options)
|
963
|
-
}).join(' ')
|
964
|
-
}
|
965
|
-
|
966
|
-
function replaceCaret(comp, options) {
|
967
|
-
debug('caret', comp, options)
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
if (isX(
|
976
|
-
ret = ''
|
977
|
-
else if (isX(
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
ret = '>=' + M + '.' + m + '.0 <' +
|
982
|
-
|
983
|
-
ret = '>=' + M + '.' + m + '.0 <' + (+M + 1) + '.0.0';
|
1023
|
+
function replaceCarets (comp, options) {
|
1024
|
+
return comp.trim().split(/\s+/).map(function (comp) {
|
1025
|
+
return replaceCaret(comp, options)
|
1026
|
+
}).join(' ')
|
1027
|
+
}
|
1028
|
+
|
1029
|
+
function replaceCaret (comp, options) {
|
1030
|
+
debug('caret', comp, options)
|
1031
|
+
var r = options.loose ? re[CARETLOOSE] : re[CARET]
|
1032
|
+
return comp.replace(r, function (_, M, m, p, pr) {
|
1033
|
+
debug('caret', comp, _, M, m, p, pr)
|
1034
|
+
var ret
|
1035
|
+
|
1036
|
+
if (isX(M)) {
|
1037
|
+
ret = ''
|
1038
|
+
} else if (isX(m)) {
|
1039
|
+
ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0'
|
1040
|
+
} else if (isX(p)) {
|
1041
|
+
if (M === '0') {
|
1042
|
+
ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0'
|
1043
|
+
} else {
|
1044
|
+
ret = '>=' + M + '.' + m + '.0 <' + (+M + 1) + '.0.0'
|
1045
|
+
}
|
984
1046
|
} else if (pr) {
|
985
|
-
debug('replaceCaret pr', pr)
|
986
|
-
if (pr.charAt(0) !== '-')
|
987
|
-
pr = '-' + pr;
|
1047
|
+
debug('replaceCaret pr', pr)
|
988
1048
|
if (M === '0') {
|
989
|
-
if (m === '0')
|
990
|
-
ret = '>=' + M + '.' + m + '.' + p + pr +
|
991
|
-
' <' + M + '.' + m + '.' + (+p + 1)
|
992
|
-
else
|
993
|
-
ret = '>=' + M + '.' + m + '.' + p + pr +
|
994
|
-
' <' + M + '.' + (+m + 1) + '.0'
|
995
|
-
|
996
|
-
|
997
|
-
|
1049
|
+
if (m === '0') {
|
1050
|
+
ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
|
1051
|
+
' <' + M + '.' + m + '.' + (+p + 1)
|
1052
|
+
} else {
|
1053
|
+
ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
|
1054
|
+
' <' + M + '.' + (+m + 1) + '.0'
|
1055
|
+
}
|
1056
|
+
} else {
|
1057
|
+
ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
|
1058
|
+
' <' + (+M + 1) + '.0.0'
|
1059
|
+
}
|
998
1060
|
} else {
|
999
|
-
debug('no pr')
|
1061
|
+
debug('no pr')
|
1000
1062
|
if (M === '0') {
|
1001
|
-
if (m === '0')
|
1063
|
+
if (m === '0') {
|
1002
1064
|
ret = '>=' + M + '.' + m + '.' + p +
|
1003
|
-
' <' + M + '.' + m + '.' + (+p + 1)
|
1004
|
-
else
|
1065
|
+
' <' + M + '.' + m + '.' + (+p + 1)
|
1066
|
+
} else {
|
1005
1067
|
ret = '>=' + M + '.' + m + '.' + p +
|
1006
|
-
' <' + M + '.' + (+m + 1) + '.0'
|
1007
|
-
|
1068
|
+
' <' + M + '.' + (+m + 1) + '.0'
|
1069
|
+
}
|
1070
|
+
} else {
|
1008
1071
|
ret = '>=' + M + '.' + m + '.' + p +
|
1009
|
-
' <' + (+M + 1) + '.0.0'
|
1072
|
+
' <' + (+M + 1) + '.0.0'
|
1073
|
+
}
|
1010
1074
|
}
|
1011
1075
|
|
1012
|
-
debug('caret return', ret)
|
1013
|
-
return ret
|
1014
|
-
})
|
1076
|
+
debug('caret return', ret)
|
1077
|
+
return ret
|
1078
|
+
})
|
1015
1079
|
}
|
1016
1080
|
|
1017
|
-
function replaceXRanges(comp, options) {
|
1018
|
-
debug('replaceXRanges', comp, options)
|
1019
|
-
return comp.split(/\s+/).map(function(comp) {
|
1020
|
-
return replaceXRange(comp, options)
|
1021
|
-
}).join(' ')
|
1081
|
+
function replaceXRanges (comp, options) {
|
1082
|
+
debug('replaceXRanges', comp, options)
|
1083
|
+
return comp.split(/\s+/).map(function (comp) {
|
1084
|
+
return replaceXRange(comp, options)
|
1085
|
+
}).join(' ')
|
1022
1086
|
}
|
1023
1087
|
|
1024
|
-
function replaceXRange(comp, options) {
|
1025
|
-
comp = comp.trim()
|
1026
|
-
|
1027
|
-
|
1028
|
-
|
1029
|
-
|
1030
|
-
|
1031
|
-
var
|
1032
|
-
var
|
1033
|
-
|
1034
|
-
|
1035
|
-
|
1036
|
-
|
1037
|
-
gtlt = '';
|
1088
|
+
function replaceXRange (comp, options) {
|
1089
|
+
comp = comp.trim()
|
1090
|
+
var r = options.loose ? re[XRANGELOOSE] : re[XRANGE]
|
1091
|
+
return comp.replace(r, function (ret, gtlt, M, m, p, pr) {
|
1092
|
+
debug('xRange', comp, ret, gtlt, M, m, p, pr)
|
1093
|
+
var xM = isX(M)
|
1094
|
+
var xm = xM || isX(m)
|
1095
|
+
var xp = xm || isX(p)
|
1096
|
+
var anyX = xp
|
1097
|
+
|
1098
|
+
if (gtlt === '=' && anyX) {
|
1099
|
+
gtlt = ''
|
1100
|
+
}
|
1038
1101
|
|
1039
1102
|
if (xM) {
|
1040
1103
|
if (gtlt === '>' || gtlt === '<') {
|
1041
1104
|
// nothing is allowed
|
1042
|
-
ret = '<0.0.0'
|
1105
|
+
ret = '<0.0.0'
|
1043
1106
|
} else {
|
1044
1107
|
// nothing is forbidden
|
1045
|
-
ret = '*'
|
1108
|
+
ret = '*'
|
1046
1109
|
}
|
1047
1110
|
} else if (gtlt && anyX) {
|
1111
|
+
// we know patch is an x, because we have any x at all.
|
1048
1112
|
// replace X with 0
|
1049
|
-
if (xm)
|
1050
|
-
m = 0
|
1051
|
-
|
1052
|
-
|
1113
|
+
if (xm) {
|
1114
|
+
m = 0
|
1115
|
+
}
|
1116
|
+
p = 0
|
1053
1117
|
|
1054
1118
|
if (gtlt === '>') {
|
1055
1119
|
// >1 => >=2.0.0
|
1056
1120
|
// >1.2 => >=1.3.0
|
1057
1121
|
// >1.2.3 => >= 1.2.4
|
1058
|
-
gtlt = '>='
|
1122
|
+
gtlt = '>='
|
1059
1123
|
if (xm) {
|
1060
|
-
M = +M + 1
|
1061
|
-
m = 0
|
1062
|
-
p = 0
|
1063
|
-
} else
|
1064
|
-
m = +m + 1
|
1065
|
-
p = 0
|
1124
|
+
M = +M + 1
|
1125
|
+
m = 0
|
1126
|
+
p = 0
|
1127
|
+
} else {
|
1128
|
+
m = +m + 1
|
1129
|
+
p = 0
|
1066
1130
|
}
|
1067
1131
|
} else if (gtlt === '<=') {
|
1068
1132
|
// <=0.7.x is actually <0.8.0, since any 0.7.x should
|
1069
1133
|
// pass. Similarly, <=7.x is actually <8.0.0, etc.
|
1070
|
-
gtlt = '<'
|
1071
|
-
if (xm)
|
1072
|
-
M = +M + 1
|
1073
|
-
else
|
1074
|
-
m = +m + 1
|
1134
|
+
gtlt = '<'
|
1135
|
+
if (xm) {
|
1136
|
+
M = +M + 1
|
1137
|
+
} else {
|
1138
|
+
m = +m + 1
|
1139
|
+
}
|
1075
1140
|
}
|
1076
1141
|
|
1077
|
-
ret = gtlt + M + '.' + m + '.' + p
|
1142
|
+
ret = gtlt + M + '.' + m + '.' + p
|
1078
1143
|
} else if (xm) {
|
1079
|
-
ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0'
|
1144
|
+
ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0'
|
1080
1145
|
} else if (xp) {
|
1081
|
-
ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0'
|
1146
|
+
ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0'
|
1082
1147
|
}
|
1083
1148
|
|
1084
|
-
debug('xRange return', ret)
|
1149
|
+
debug('xRange return', ret)
|
1085
1150
|
|
1086
|
-
return ret
|
1087
|
-
})
|
1151
|
+
return ret
|
1152
|
+
})
|
1088
1153
|
}
|
1089
1154
|
|
1090
1155
|
// Because * is AND-ed with everything else in the comparator,
|
1091
1156
|
// and '' means "any version", just remove the *s entirely.
|
1092
|
-
function replaceStars(comp, options) {
|
1093
|
-
debug('replaceStars', comp, options)
|
1157
|
+
function replaceStars (comp, options) {
|
1158
|
+
debug('replaceStars', comp, options)
|
1094
1159
|
// Looseness is ignored here. star is always as loose as it gets!
|
1095
|
-
return comp.trim().replace(re[STAR], '')
|
1160
|
+
return comp.trim().replace(re[STAR], '')
|
1096
1161
|
}
|
1097
1162
|
|
1098
1163
|
// This function is passed to string.replace(re[HYPHENRANGE])
|
@@ -1100,253 +1165,319 @@ function replaceStars(comp, options) {
|
|
1100
1165
|
// 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
|
1101
1166
|
// 1.2.3 - 3.4 => >=1.2.0 <3.5.0 Any 3.4.x will do
|
1102
1167
|
// 1.2 - 3.4 => >=1.2.0 <3.5.0
|
1103
|
-
function hyphenReplace($0,
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1109
|
-
|
1110
|
-
|
1111
|
-
|
1112
|
-
|
1113
|
-
|
1114
|
-
|
1115
|
-
|
1116
|
-
if (isX(tM))
|
1117
|
-
to = ''
|
1118
|
-
else if (isX(tm))
|
1119
|
-
to = '<' + (+tM + 1) + '.0.0'
|
1120
|
-
else if (isX(tp))
|
1121
|
-
to = '<' + tM + '.' + (+tm + 1) + '.0'
|
1122
|
-
else if (tpr)
|
1123
|
-
to = '<=' + tM + '.' + tm + '.' + tp + '-' + tpr
|
1124
|
-
else
|
1125
|
-
to = '<=' + to
|
1126
|
-
|
1127
|
-
return (from + ' ' + to).trim();
|
1128
|
-
}
|
1168
|
+
function hyphenReplace ($0,
|
1169
|
+
from, fM, fm, fp, fpr, fb,
|
1170
|
+
to, tM, tm, tp, tpr, tb) {
|
1171
|
+
if (isX(fM)) {
|
1172
|
+
from = ''
|
1173
|
+
} else if (isX(fm)) {
|
1174
|
+
from = '>=' + fM + '.0.0'
|
1175
|
+
} else if (isX(fp)) {
|
1176
|
+
from = '>=' + fM + '.' + fm + '.0'
|
1177
|
+
} else {
|
1178
|
+
from = '>=' + from
|
1179
|
+
}
|
1180
|
+
|
1181
|
+
if (isX(tM)) {
|
1182
|
+
to = ''
|
1183
|
+
} else if (isX(tm)) {
|
1184
|
+
to = '<' + (+tM + 1) + '.0.0'
|
1185
|
+
} else if (isX(tp)) {
|
1186
|
+
to = '<' + tM + '.' + (+tm + 1) + '.0'
|
1187
|
+
} else if (tpr) {
|
1188
|
+
to = '<=' + tM + '.' + tm + '.' + tp + '-' + tpr
|
1189
|
+
} else {
|
1190
|
+
to = '<=' + to
|
1191
|
+
}
|
1129
1192
|
|
1193
|
+
return (from + ' ' + to).trim()
|
1194
|
+
}
|
1130
1195
|
|
1131
1196
|
// if ANY of the sets match ALL of its comparators, then pass
|
1132
|
-
Range.prototype.test = function(version) {
|
1133
|
-
if (!version)
|
1134
|
-
return false
|
1197
|
+
Range.prototype.test = function (version) {
|
1198
|
+
if (!version) {
|
1199
|
+
return false
|
1200
|
+
}
|
1135
1201
|
|
1136
|
-
if (typeof version === 'string')
|
1137
|
-
version = new SemVer(version, this.options)
|
1202
|
+
if (typeof version === 'string') {
|
1203
|
+
version = new SemVer(version, this.options)
|
1204
|
+
}
|
1138
1205
|
|
1139
1206
|
for (var i = 0; i < this.set.length; i++) {
|
1140
|
-
if (testSet(this.set[i], version, this.options))
|
1141
|
-
return true
|
1207
|
+
if (testSet(this.set[i], version, this.options)) {
|
1208
|
+
return true
|
1209
|
+
}
|
1142
1210
|
}
|
1143
|
-
return false
|
1144
|
-
}
|
1211
|
+
return false
|
1212
|
+
}
|
1145
1213
|
|
1146
|
-
function testSet(set, version, options) {
|
1214
|
+
function testSet (set, version, options) {
|
1147
1215
|
for (var i = 0; i < set.length; i++) {
|
1148
|
-
if (!set[i].test(version))
|
1149
|
-
return false
|
1216
|
+
if (!set[i].test(version)) {
|
1217
|
+
return false
|
1218
|
+
}
|
1150
1219
|
}
|
1151
1220
|
|
1152
|
-
if (!options)
|
1153
|
-
options = {}
|
1154
|
-
|
1155
1221
|
if (version.prerelease.length && !options.includePrerelease) {
|
1156
1222
|
// Find the set of versions that are allowed to have prereleases
|
1157
1223
|
// For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0
|
1158
1224
|
// That should allow `1.2.3-pr.2` to pass.
|
1159
1225
|
// However, `1.2.4-alpha.notready` should NOT be allowed,
|
1160
1226
|
// even though it's within the range set by the comparators.
|
1161
|
-
for (
|
1162
|
-
debug(set[i].semver)
|
1163
|
-
if (set[i].semver === ANY)
|
1164
|
-
continue
|
1227
|
+
for (i = 0; i < set.length; i++) {
|
1228
|
+
debug(set[i].semver)
|
1229
|
+
if (set[i].semver === ANY) {
|
1230
|
+
continue
|
1231
|
+
}
|
1165
1232
|
|
1166
1233
|
if (set[i].semver.prerelease.length > 0) {
|
1167
|
-
var allowed = set[i].semver
|
1234
|
+
var allowed = set[i].semver
|
1168
1235
|
if (allowed.major === version.major &&
|
1169
1236
|
allowed.minor === version.minor &&
|
1170
|
-
allowed.patch === version.patch)
|
1171
|
-
return true
|
1237
|
+
allowed.patch === version.patch) {
|
1238
|
+
return true
|
1239
|
+
}
|
1172
1240
|
}
|
1173
1241
|
}
|
1174
1242
|
|
1175
1243
|
// Version has a -pre, but it's not one of the ones we like.
|
1176
|
-
return false
|
1244
|
+
return false
|
1177
1245
|
}
|
1178
1246
|
|
1179
|
-
return true
|
1247
|
+
return true
|
1180
1248
|
}
|
1181
1249
|
|
1182
|
-
exports.satisfies = satisfies
|
1183
|
-
function satisfies(version, range, options) {
|
1250
|
+
exports.satisfies = satisfies
|
1251
|
+
function satisfies (version, range, options) {
|
1184
1252
|
try {
|
1185
|
-
range = new Range(range, options)
|
1253
|
+
range = new Range(range, options)
|
1186
1254
|
} catch (er) {
|
1187
|
-
return false
|
1255
|
+
return false
|
1188
1256
|
}
|
1189
|
-
return range.test(version)
|
1257
|
+
return range.test(version)
|
1190
1258
|
}
|
1191
1259
|
|
1192
|
-
exports.maxSatisfying = maxSatisfying
|
1193
|
-
function maxSatisfying(versions, range, options) {
|
1194
|
-
var max = null
|
1195
|
-
var maxSV = null
|
1260
|
+
exports.maxSatisfying = maxSatisfying
|
1261
|
+
function maxSatisfying (versions, range, options) {
|
1262
|
+
var max = null
|
1263
|
+
var maxSV = null
|
1196
1264
|
try {
|
1197
|
-
var rangeObj = new Range(range, options)
|
1265
|
+
var rangeObj = new Range(range, options)
|
1198
1266
|
} catch (er) {
|
1199
|
-
return null
|
1267
|
+
return null
|
1200
1268
|
}
|
1201
1269
|
versions.forEach(function (v) {
|
1202
|
-
if (rangeObj.test(v)) {
|
1203
|
-
|
1204
|
-
|
1205
|
-
|
1270
|
+
if (rangeObj.test(v)) {
|
1271
|
+
// satisfies(v, range, options)
|
1272
|
+
if (!max || maxSV.compare(v) === -1) {
|
1273
|
+
// compare(max, v, true)
|
1274
|
+
max = v
|
1275
|
+
maxSV = new SemVer(max, options)
|
1206
1276
|
}
|
1207
1277
|
}
|
1208
1278
|
})
|
1209
|
-
return max
|
1279
|
+
return max
|
1210
1280
|
}
|
1211
1281
|
|
1212
|
-
exports.minSatisfying = minSatisfying
|
1213
|
-
function minSatisfying(versions, range, options) {
|
1214
|
-
var min = null
|
1215
|
-
var minSV = null
|
1282
|
+
exports.minSatisfying = minSatisfying
|
1283
|
+
function minSatisfying (versions, range, options) {
|
1284
|
+
var min = null
|
1285
|
+
var minSV = null
|
1216
1286
|
try {
|
1217
|
-
var rangeObj = new Range(range, options)
|
1287
|
+
var rangeObj = new Range(range, options)
|
1218
1288
|
} catch (er) {
|
1219
|
-
return null
|
1289
|
+
return null
|
1220
1290
|
}
|
1221
1291
|
versions.forEach(function (v) {
|
1222
|
-
if (rangeObj.test(v)) {
|
1223
|
-
|
1224
|
-
|
1225
|
-
|
1292
|
+
if (rangeObj.test(v)) {
|
1293
|
+
// satisfies(v, range, options)
|
1294
|
+
if (!min || minSV.compare(v) === 1) {
|
1295
|
+
// compare(min, v, true)
|
1296
|
+
min = v
|
1297
|
+
minSV = new SemVer(min, options)
|
1226
1298
|
}
|
1227
1299
|
}
|
1228
1300
|
})
|
1229
|
-
return min
|
1301
|
+
return min
|
1230
1302
|
}
|
1231
1303
|
|
1232
|
-
exports.
|
1233
|
-
function
|
1304
|
+
exports.minVersion = minVersion
|
1305
|
+
function minVersion (range, loose) {
|
1306
|
+
range = new Range(range, loose)
|
1307
|
+
|
1308
|
+
var minver = new SemVer('0.0.0')
|
1309
|
+
if (range.test(minver)) {
|
1310
|
+
return minver
|
1311
|
+
}
|
1312
|
+
|
1313
|
+
minver = new SemVer('0.0.0-0')
|
1314
|
+
if (range.test(minver)) {
|
1315
|
+
return minver
|
1316
|
+
}
|
1317
|
+
|
1318
|
+
minver = null
|
1319
|
+
for (var i = 0; i < range.set.length; ++i) {
|
1320
|
+
var comparators = range.set[i]
|
1321
|
+
|
1322
|
+
comparators.forEach(function (comparator) {
|
1323
|
+
// Clone to avoid manipulating the comparator's semver object.
|
1324
|
+
var compver = new SemVer(comparator.semver.version)
|
1325
|
+
switch (comparator.operator) {
|
1326
|
+
case '>':
|
1327
|
+
if (compver.prerelease.length === 0) {
|
1328
|
+
compver.patch++
|
1329
|
+
} else {
|
1330
|
+
compver.prerelease.push(0)
|
1331
|
+
}
|
1332
|
+
compver.raw = compver.format()
|
1333
|
+
/* fallthrough */
|
1334
|
+
case '':
|
1335
|
+
case '>=':
|
1336
|
+
if (!minver || gt(minver, compver)) {
|
1337
|
+
minver = compver
|
1338
|
+
}
|
1339
|
+
break
|
1340
|
+
case '<':
|
1341
|
+
case '<=':
|
1342
|
+
/* Ignore maximum versions */
|
1343
|
+
break
|
1344
|
+
/* istanbul ignore next */
|
1345
|
+
default:
|
1346
|
+
throw new Error('Unexpected operation: ' + comparator.operator)
|
1347
|
+
}
|
1348
|
+
})
|
1349
|
+
}
|
1350
|
+
|
1351
|
+
if (minver && range.test(minver)) {
|
1352
|
+
return minver
|
1353
|
+
}
|
1354
|
+
|
1355
|
+
return null
|
1356
|
+
}
|
1357
|
+
|
1358
|
+
exports.validRange = validRange
|
1359
|
+
function validRange (range, options) {
|
1234
1360
|
try {
|
1235
1361
|
// Return '*' instead of '' so that truthiness works.
|
1236
1362
|
// This will throw if it's invalid anyway
|
1237
|
-
return new Range(range, options).range || '*'
|
1363
|
+
return new Range(range, options).range || '*'
|
1238
1364
|
} catch (er) {
|
1239
|
-
return null
|
1365
|
+
return null
|
1240
1366
|
}
|
1241
1367
|
}
|
1242
1368
|
|
1243
1369
|
// Determine if version is less than all the versions possible in the range
|
1244
|
-
exports.ltr = ltr
|
1245
|
-
function ltr(version, range, options) {
|
1246
|
-
return outside(version, range, '<', options)
|
1370
|
+
exports.ltr = ltr
|
1371
|
+
function ltr (version, range, options) {
|
1372
|
+
return outside(version, range, '<', options)
|
1247
1373
|
}
|
1248
1374
|
|
1249
1375
|
// Determine if version is greater than all the versions possible in the range.
|
1250
|
-
exports.gtr = gtr
|
1251
|
-
function gtr(version, range, options) {
|
1252
|
-
return outside(version, range, '>', options)
|
1376
|
+
exports.gtr = gtr
|
1377
|
+
function gtr (version, range, options) {
|
1378
|
+
return outside(version, range, '>', options)
|
1253
1379
|
}
|
1254
1380
|
|
1255
|
-
exports.outside = outside
|
1256
|
-
function outside(version, range, hilo, options) {
|
1257
|
-
version = new SemVer(version, options)
|
1258
|
-
range = new Range(range, options)
|
1381
|
+
exports.outside = outside
|
1382
|
+
function outside (version, range, hilo, options) {
|
1383
|
+
version = new SemVer(version, options)
|
1384
|
+
range = new Range(range, options)
|
1259
1385
|
|
1260
|
-
var gtfn, ltefn, ltfn, comp, ecomp
|
1386
|
+
var gtfn, ltefn, ltfn, comp, ecomp
|
1261
1387
|
switch (hilo) {
|
1262
1388
|
case '>':
|
1263
|
-
gtfn = gt
|
1264
|
-
ltefn = lte
|
1265
|
-
ltfn = lt
|
1266
|
-
comp = '>'
|
1267
|
-
ecomp = '>='
|
1268
|
-
break
|
1389
|
+
gtfn = gt
|
1390
|
+
ltefn = lte
|
1391
|
+
ltfn = lt
|
1392
|
+
comp = '>'
|
1393
|
+
ecomp = '>='
|
1394
|
+
break
|
1269
1395
|
case '<':
|
1270
|
-
gtfn = lt
|
1271
|
-
ltefn = gte
|
1272
|
-
ltfn = gt
|
1273
|
-
comp = '<'
|
1274
|
-
ecomp = '<='
|
1275
|
-
break
|
1396
|
+
gtfn = lt
|
1397
|
+
ltefn = gte
|
1398
|
+
ltfn = gt
|
1399
|
+
comp = '<'
|
1400
|
+
ecomp = '<='
|
1401
|
+
break
|
1276
1402
|
default:
|
1277
|
-
throw new TypeError('Must provide a hilo val of "<" or ">"')
|
1403
|
+
throw new TypeError('Must provide a hilo val of "<" or ">"')
|
1278
1404
|
}
|
1279
1405
|
|
1280
1406
|
// If it satisifes the range it is not outside
|
1281
1407
|
if (satisfies(version, range, options)) {
|
1282
|
-
return false
|
1408
|
+
return false
|
1283
1409
|
}
|
1284
1410
|
|
1285
1411
|
// From now on, variable terms are as if we're in "gtr" mode.
|
1286
1412
|
// but note that everything is flipped for the "ltr" function.
|
1287
1413
|
|
1288
1414
|
for (var i = 0; i < range.set.length; ++i) {
|
1289
|
-
var comparators = range.set[i]
|
1415
|
+
var comparators = range.set[i]
|
1290
1416
|
|
1291
|
-
var high = null
|
1292
|
-
var low = null
|
1417
|
+
var high = null
|
1418
|
+
var low = null
|
1293
1419
|
|
1294
|
-
comparators.forEach(function(comparator) {
|
1420
|
+
comparators.forEach(function (comparator) {
|
1295
1421
|
if (comparator.semver === ANY) {
|
1296
1422
|
comparator = new Comparator('>=0.0.0')
|
1297
1423
|
}
|
1298
|
-
high = high || comparator
|
1299
|
-
low = low || comparator
|
1424
|
+
high = high || comparator
|
1425
|
+
low = low || comparator
|
1300
1426
|
if (gtfn(comparator.semver, high.semver, options)) {
|
1301
|
-
high = comparator
|
1427
|
+
high = comparator
|
1302
1428
|
} else if (ltfn(comparator.semver, low.semver, options)) {
|
1303
|
-
low = comparator
|
1429
|
+
low = comparator
|
1304
1430
|
}
|
1305
|
-
})
|
1431
|
+
})
|
1306
1432
|
|
1307
1433
|
// If the edge version comparator has a operator then our version
|
1308
1434
|
// isn't outside it
|
1309
1435
|
if (high.operator === comp || high.operator === ecomp) {
|
1310
|
-
return false
|
1436
|
+
return false
|
1311
1437
|
}
|
1312
1438
|
|
1313
1439
|
// If the lowest version comparator has an operator and our version
|
1314
1440
|
// is less than it then it isn't higher than the range
|
1315
1441
|
if ((!low.operator || low.operator === comp) &&
|
1316
1442
|
ltefn(version, low.semver)) {
|
1317
|
-
return false
|
1443
|
+
return false
|
1318
1444
|
} else if (low.operator === ecomp && ltfn(version, low.semver)) {
|
1319
|
-
return false
|
1445
|
+
return false
|
1320
1446
|
}
|
1321
1447
|
}
|
1322
|
-
return true
|
1448
|
+
return true
|
1323
1449
|
}
|
1324
1450
|
|
1325
|
-
exports.prerelease = prerelease
|
1326
|
-
function prerelease(version, options) {
|
1327
|
-
var parsed = parse(version, options)
|
1328
|
-
return (parsed && parsed.prerelease.length) ? parsed.prerelease : null
|
1451
|
+
exports.prerelease = prerelease
|
1452
|
+
function prerelease (version, options) {
|
1453
|
+
var parsed = parse(version, options)
|
1454
|
+
return (parsed && parsed.prerelease.length) ? parsed.prerelease : null
|
1329
1455
|
}
|
1330
1456
|
|
1331
|
-
exports.intersects = intersects
|
1332
|
-
function intersects(r1, r2, options) {
|
1457
|
+
exports.intersects = intersects
|
1458
|
+
function intersects (r1, r2, options) {
|
1333
1459
|
r1 = new Range(r1, options)
|
1334
1460
|
r2 = new Range(r2, options)
|
1335
1461
|
return r1.intersects(r2)
|
1336
1462
|
}
|
1337
1463
|
|
1338
|
-
exports.coerce = coerce
|
1339
|
-
function coerce(version) {
|
1340
|
-
if (version instanceof SemVer)
|
1341
|
-
return version
|
1464
|
+
exports.coerce = coerce
|
1465
|
+
function coerce (version) {
|
1466
|
+
if (version instanceof SemVer) {
|
1467
|
+
return version
|
1468
|
+
}
|
1342
1469
|
|
1343
|
-
if (typeof version !== 'string')
|
1344
|
-
return null
|
1470
|
+
if (typeof version !== 'string') {
|
1471
|
+
return null
|
1472
|
+
}
|
1345
1473
|
|
1346
|
-
var match = version.match(re[COERCE])
|
1474
|
+
var match = version.match(re[COERCE])
|
1347
1475
|
|
1348
|
-
if (match == null)
|
1349
|
-
return null
|
1476
|
+
if (match == null) {
|
1477
|
+
return null
|
1478
|
+
}
|
1350
1479
|
|
1351
|
-
return parse(
|
1480
|
+
return parse(match[1] +
|
1481
|
+
'.' + (match[2] || '0') +
|
1482
|
+
'.' + (match[3] || '0'))
|
1352
1483
|
}
|