This repository has been archived by the owner on Nov 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
semver-umd.d.ts
308 lines (271 loc) · 11.9 KB
/
semver-umd.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
declare module 'semver-umd' {
// Type definitions for semver 6.2
// Project: https://github.com/npm/node-semver
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
// BendingBender <https://github.com/BendingBender>
// Lucian Buzzo <https://github.com/LucianBuzzo>
// Klaus Meinhardt <https://github.com/ajafff>
// ExE Boss <https://github.com/ExE-Boss>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/semver
export const SEMVER_SPEC_VERSION: "2.0.0";
export type ReleaseType = "major" | "premajor" | "minor" | "preminor" | "patch" | "prepatch" | "prerelease";
export interface Options {
loose?: boolean;
includePrerelease?: boolean;
}
export interface CoerceOptions extends Options {
/**
* Used by `coerce()` to coerce from right to left.
*
* @default false
*
* @example
* coerce('1.2.3.4', { rtl: true });
* // => SemVer { version: '2.3.4', ... }
*
* @since 6.2.0
*/
rtl?: boolean;
}
/**
* Return the parsed version as a SemVer object, or null if it's not valid.
*/
export function parse(version: string | SemVer | null | undefined, optionsOrLoose?: boolean | Options): SemVer | null;
/**
* Return the parsed version as a string, or null if it's not valid.
*/
export function valid(version: string | SemVer | null | undefined, optionsOrLoose?: boolean | Options): string | null;
/**
* Coerces a string to SemVer if possible
*/
export function coerce(version: string | number | SemVer | null | undefined, options?: CoerceOptions): SemVer | null;
/**
* Returns cleaned (removed leading/trailing whitespace, remove '=v' prefix) and parsed version, or null if version is invalid.
*/
export function clean(version: string, optionsOrLoose?: boolean | Options): string | null;
/**
* Return the version incremented by the release type (major, minor, patch, or prerelease), or null if it's not valid.
*/
export function inc(version: string | SemVer, release: ReleaseType, optionsOrLoose?: boolean | Options, identifier?: string): string | null;
export function inc(version: string | SemVer, release: ReleaseType, identifier?: string): string | null;
/**
* Return the major version number.
*/
export function major(version: string | SemVer, optionsOrLoose?: boolean | Options): number;
/**
* Return the minor version number.
*/
export function minor(version: string | SemVer, optionsOrLoose?: boolean | Options): number;
/**
* Return the patch version number.
*/
export function patch(version: string | SemVer, optionsOrLoose?: boolean | Options): number;
/**
* Returns an array of prerelease components, or null if none exist.
*/
export function prerelease(version: string | SemVer, optionsOrLoose?: boolean | Options): ReadonlyArray<string> | null;
// Comparison
/**
* v1 > v2
*/
export function gt(v1: string | SemVer, v2: string | SemVer, optionsOrLoose?: boolean | Options): boolean;
/**
* v1 >= v2
*/
export function gte(v1: string | SemVer, v2: string | SemVer, optionsOrLoose?: boolean | Options): boolean;
/**
* v1 < v2
*/
export function lt(v1: string | SemVer, v2: string | SemVer, optionsOrLoose?: boolean | Options): boolean;
/**
* v1 <= v2
*/
export function lte(v1: string | SemVer, v2: string | SemVer, optionsOrLoose?: boolean | Options): boolean;
/**
* v1 == v2 This is true if they're logically equivalent, even if they're not the exact same string. You already know how to compare strings.
*/
export function eq(v1: string | SemVer, v2: string | SemVer, optionsOrLoose?: boolean | Options): boolean;
/**
* v1 != v2 The opposite of eq.
*/
export function neq(v1: string | SemVer, v2: string | SemVer, optionsOrLoose?: boolean | Options): boolean;
/**
* Pass in a comparison string, and it'll call the corresponding semver comparison function.
* "===" and "!==" do simple string comparison, but are included for completeness.
* Throws if an invalid comparison string is provided.
*/
export function cmp(v1: string | SemVer, operator: Operator, v2: string | SemVer, optionsOrLoose?: boolean | Options): boolean;
export type Operator = '===' | '!==' | '' | '=' | '==' | '!=' | '>' | '>=' | '<' | '<=';
/**
* Compares two versions excluding build identifiers (the bit after `+` in the semantic version string).
*
* Sorts in ascending order when passed to `Array.sort()`.
*
* @return
* - `0` if `v1` == `v2`
* - `1` if `v1` is greater
* - `-1` if `v2` is greater.
*/
export function compare(v1: string | SemVer, v2: string | SemVer, optionsOrLoose?: boolean | Options): 1 | 0 | -1;
/**
* The reverse of compare.
*
* Sorts in descending order when passed to `Array.sort()`.
*/
export function rcompare(v1: string | SemVer, v2: string | SemVer, optionsOrLoose?: boolean | Options): 1 | 0 | -1;
/**
* Compares two identifiers, must be numeric strings or truthy/falsy values.
*
* Sorts in ascending order when passed to `Array.sort()`.
*/
export function compareIdentifiers(a: string | null | undefined, b: string | null | undefined): 1 | 0 | -1;
/**
* The reverse of compareIdentifiers.
*
* Sorts in descending order when passed to `Array.sort()`.
*/
export function rcompareIdentifiers(a: string | null | undefined, b: string | null | undefined): 1 | 0 | -1;
/**
* Compares two versions including build identifiers (the bit after `+` in the semantic version string).
*
* Sorts in ascending order when passed to `Array.sort()`.
*
* @return
* - `0` if `v1` == `v2`
* - `1` if `v1` is greater
* - `-1` if `v2` is greater.
*
* @since 6.1.0
*/
export function compareBuild(a: string | SemVer, b: string | SemVer): 1 | 0 | -1;
/**
* Sorts an array of semver entries in ascending order using `compareBuild()`.
*/
export function sort<T extends string | SemVer>(list: T[], optionsOrLoose?: boolean | Options): T[];
/**
* Sorts an array of semver entries in descending order using `compareBuild()`.
*/
export function rsort<T extends string | SemVer>(list: T[], optionsOrLoose?: boolean | Options): T[];
/**
* Returns difference between two versions by the release type (major, premajor, minor, preminor, patch, prepatch, or prerelease), or null if the versions are the same.
*/
export function diff(v1: string | SemVer, v2: string | SemVer, optionsOrLoose?: boolean | Options): ReleaseType | null;
// Ranges
/**
* Return the valid range or null if it's not valid
*/
export function validRange(range: string | Range | null | undefined, optionsOrLoose?: boolean | Options): string;
/**
* Return true if the version satisfies the range.
*/
export function satisfies(version: string | SemVer, range: string | Range, optionsOrLoose?: boolean | Options): boolean;
/**
* Return the highest version in the list that satisfies the range, or null if none of them do.
*/
export function maxSatisfying<T extends string | SemVer>(versions: ReadonlyArray<T>, range: string | Range, optionsOrLoose?: boolean | Options): T | null;
/**
* Return the lowest version in the list that satisfies the range, or null if none of them do.
*/
export function minSatisfying<T extends string | SemVer>(versions: ReadonlyArray<T>, range: string | Range, optionsOrLoose?: boolean | Options): T | null;
/**
* Return the lowest version that can possibly match the given range.
*/
export function minVersion(range: string | Range, optionsOrLoose?: boolean | Options): SemVer | null;
/**
* Return true if version is greater than all the versions possible in the range.
*/
export function gtr(version: string | SemVer, range: string | Range, optionsOrLoose?: boolean | Options): boolean;
/**
* Return true if version is less than all the versions possible in the range.
*/
export function ltr(version: string | SemVer, range: string | Range, optionsOrLoose?: boolean | Options): boolean;
/**
* Return true if the version is outside the bounds of the range in either the high or low direction.
* The hilo argument must be either the string '>' or '<'. (This is the function called by gtr and ltr.)
*/
export function outside(version: string | SemVer, range: string | Range, hilo: '>' | '<', optionsOrLoose?: boolean | Options): boolean;
/**
* Return true if any of the ranges comparators intersect
*/
export function intersects(range1: string | Range, range2: string | Range, optionsOrLoose?: boolean | Options): boolean;
export class SemVer {
constructor(version: string | SemVer, optionsOrLoose?: boolean | Options);
raw: string;
loose: boolean;
options: Options;
format(): string;
inspect(): string;
major: number;
minor: number;
patch: number;
version: string;
build: ReadonlyArray<string>;
prerelease: ReadonlyArray<string | number>;
/**
* Compares two versions excluding build identifiers (the bit after `+` in the semantic version string).
*
* @return
* - `0` if `this` == `other`
* - `1` if `this` is greater
* - `-1` if `other` is greater.
*/
compare(other: string | SemVer): 1 | 0 | -1;
/**
* Compares the release portion of two versions.
*
* @return
* - `0` if `this` == `other`
* - `1` if `this` is greater
* - `-1` if `other` is greater.
*/
compareMain(other: string | SemVer): 1 | 0 | -1;
/**
* Compares the prerelease portion of two versions.
*
* @return
* - `0` if `this` == `other`
* - `1` if `this` is greater
* - `-1` if `other` is greater.
*/
comparePre(other: string | SemVer): 1 | 0 | -1;
/**
* Compares the build identifier of two versions.
*
* @return
* - `0` if `this` == `other`
* - `1` if `this` is greater
* - `-1` if `other` is greater.
*/
compareBuild(other: string | SemVer): 1 | 0 | -1;
inc(release: ReleaseType, identifier?: string): SemVer;
}
export class Comparator {
constructor(comp: string | Comparator, optionsOrLoose?: boolean | Options);
semver: SemVer;
operator: '' | '=' | '<' | '>' | '<=' | '>=';
value: string;
loose: boolean;
options: Options;
parse(comp: string): void;
test(version: string | SemVer): boolean;
intersects(comp: Comparator, optionsOrLoose?: boolean | Options): boolean;
}
export class Range {
constructor(range: string | Range, optionsOrLoose?: boolean | Options);
range: string;
raw: string;
loose: boolean;
options: Options;
includePrerelease: boolean;
format(): string;
inspect(): string;
set: ReadonlyArray<ReadonlyArray<Comparator>>;
parseRange(range: string): ReadonlyArray<Comparator>;
test(version: string | SemVer): boolean;
intersects(range: Range, optionsOrLoose?: boolean | Options): boolean;
}
}