-
Notifications
You must be signed in to change notification settings - Fork 248
/
semver_v7.x.x.js
232 lines (216 loc) · 5.92 KB
/
semver_v7.x.x.js
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
// flow-typed signature: bf6205896c200fb28700dfa8d29f2b8a
// flow-typed version: 3d76504c27/semver_v7.x.x/flow_>=v0.104.x
declare module "semver" {
declare type Release =
| "major"
| "premajor"
| "minor"
| "preminor"
| "patch"
| "prepatch"
| "prerelease";
// The supported comparators are taken from the source here:
// https://github.com/npm/node-semver/blob/8bd070b550db2646362c9883c8d008d32f66a234/semver.js#L623
declare type Operator =
| "==="
| "!=="
| "=="
| "="
| "" // Not sure why you would want this, but whatever.
| "!="
| ">"
| ">="
| "<"
| "<=";
declare class SemVer {
build: Array<string>;
loose: ?boolean;
major: number;
minor: number;
patch: number;
prerelease: Array<string | number>;
raw: string;
version: string;
constructor(version: string | SemVer, options?: Options): SemVer;
compare(other: string | SemVer): -1 | 0 | 1;
compareMain(other: string | SemVer): -1 | 0 | 1;
comparePre(other: string | SemVer): -1 | 0 | 1;
compareBuild(other: string | SemVer): -1 | 0 | 1;
format(): string;
inc(release: Release, identifier: string): this;
}
declare class Comparator {
options?: Options;
operator: Operator;
semver: SemVer;
value: string;
constructor(comp: string | Comparator, options?: Options): Comparator;
parse(comp: string): void;
test(version: string): boolean;
}
declare class Range {
loose: ?boolean;
raw: string;
set: Array<Array<Comparator>>;
constructor(range: string | Range, options?: Options): Range;
format(): string;
parseRange(range: string): Array<Comparator>;
test(version: string): boolean;
toString(): string;
}
declare var SEMVER_SPEC_VERSION: string;
declare var re: Array<RegExp>;
declare var src: Array<string>;
declare type Options = {
options?: Options,
includePrerelease?: boolean,
...
} | boolean;
// Functions
declare function valid(v: string | SemVer, options?: Options): string | null;
declare function clean(v: string | SemVer, options?: Options): string | null;
declare function inc(
v: string | SemVer,
release: Release,
options?: Options,
identifier?: string
): string | null;
declare function inc(
v: string | SemVer,
release: Release,
identifier: string
): string | null;
declare function major(v: string | SemVer, options?: Options): number;
declare function minor(v: string | SemVer, options?: Options): number;
declare function patch(v: string | SemVer, options?: Options): number;
declare function intersects(r1: string | SemVer, r2: string | SemVer, loose?: boolean): boolean;
declare function minVersion(r: string | Range): Range | null;
// Comparison
declare function gt(
v1: string | SemVer,
v2: string | SemVer,
options?: Options
): boolean;
declare function gte(
v1: string | SemVer,
v2: string | SemVer,
options?: Options
): boolean;
declare function lt(
v1: string | SemVer,
v2: string | SemVer,
options?: Options
): boolean;
declare function lte(
v1: string | SemVer,
v2: string | SemVer,
options?: Options
): boolean;
declare function eq(
v1: string | SemVer,
v2: string | SemVer,
options?: Options
): boolean;
declare function neq(
v1: string | SemVer,
v2: string | SemVer,
options?: Options
): boolean;
declare function cmp(
v1: string | SemVer,
comparator: Operator,
v2: string | SemVer,
options?: Options
): boolean;
declare function compare(
v1: string | SemVer,
v2: string | SemVer,
options?: Options
): -1 | 0 | 1;
declare function rcompare(
v1: string | SemVer,
v2: string | SemVer,
options?: Options
): -1 | 0 | 1;
declare function diff(v1: string | SemVer, v2: string | SemVer): ?Release;
declare function intersects(comparator: Comparator): boolean;
declare function sort(
list: Array<string | SemVer>,
options?: Options
): Array<string | SemVer>;
declare function rsort(
list: Array<string | SemVer>,
options?: Options
): Array<string | SemVer>;
declare function compareIdentifiers(
v1: string | SemVer,
v2: string | SemVer
): -1 | 0 | 1;
declare function rcompareIdentifiers(
v1: string | SemVer,
v2: string | SemVer
): -1 | 0 | 1;
// Ranges
declare function validRange(
range: string | Range,
options?: Options
): string | null;
declare function satisfies(
version: string | SemVer,
range: string | Range,
options?: Options
): boolean;
declare function maxSatisfying(
versions: Array<string | SemVer>,
range: string | Range,
options?: Options
): string | SemVer | null;
declare function minSatisfying(
versions: Array<string | SemVer>,
range: string | Range,
options?: Options
): string | SemVer | null;
declare function gtr(
version: string | SemVer,
range: string | Range,
options?: Options
): boolean;
declare function ltr(
version: string | SemVer,
range: string | Range,
options?: Options
): boolean;
declare function outside(
version: string | SemVer,
range: string | Range,
hilo: ">" | "<",
options?: Options
): boolean;
declare function intersects(
range: Range
): boolean;
declare function simplifyRange(
ranges: Array<string>,
range: string | Range,
options?: Options,
): string | Range;
declare function subset(
sub: string | Range,
dom: string | Range,
options?: Options,
): boolean;
// Coercion
declare function coerce(
version: string | SemVer,
options?: Options
): ?SemVer
// Not explicitly documented, or deprecated
declare function parse(version: string, options?: Options): ?SemVer;
declare function toComparators(
range: string | Range,
options?: Options
): Array<Array<string>>;
}
declare module "semver/preload" {
declare module.exports: $Exports<"semver">;
}