forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
semver.d.ts
178 lines (162 loc) · 6.68 KB
/
semver.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
// Type definitions for semver v4.3.4
// Project: https://github.com/npm/node-semver
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/semver
declare namespace SemVerModule {
/**
* Return the parsed version, or null if it's not valid.
*/
function valid(v: string, loose?: boolean): string;
/**
* Returns cleaned (removed leading/trailing whitespace, remove '=v' prefix) and parsed version, or null if version is invalid.
*/
function clean(version: string, loose?: boolean): string;
/**
* Return the version incremented by the release type (major, minor, patch, or prerelease), or null if it's not valid.
*/
function inc(v: string, release: string, loose?: boolean): string;
/**
* Return the major version number.
*/
function major(v: string, loose?: boolean): number;
/**
* Return the minor version number.
*/
function minor(v: string, loose?: boolean): number;
/**
* Return the patch version number.
*/
function patch(v: string, loose?: boolean): number;
// Comparison
/**
* v1 > v2
*/
function gt(v1: string, v2: string, loose?: boolean): boolean;
/**
* v1 >= v2
*/
function gte(v1: string, v2: string, loose?: boolean): boolean;
/**
* v1 < v2
*/
function lt(v1: string, v2: string, loose?: boolean): boolean;
/**
* v1 <= v2
*/
function lte(v1: string, v2: string, loose?: boolean): 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.
*/
function eq(v1: string, v2: string, loose?: boolean): boolean;
/**
* v1 != v2 The opposite of eq.
*/
function neq(v1: string, v2: string, loose?: boolean): 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.
*/
function cmp(v1: string, comparator: any, v2: string, loose?: boolean): boolean;
/**
* Return 0 if v1 == v2, or 1 if v1 is greater, or -1 if v2 is greater. Sorts in ascending order if passed to Array.sort().
*/
function compare(v1: string, v2: string, loose?: boolean): number;
/**
* The reverse of compare. Sorts an array of versions in descending order when passed to Array.sort().
*/
function rcompare(v1: string, v2: string, loose?: boolean): number;
/**
* 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.
*/
function diff(v1: string, v2: string, loose?: boolean): string;
// Ranges
/**
* Return the valid range or null if it's not valid
*/
function validRange(range: string, loose?: boolean): string;
/**
* Return true if the version satisfies the range.
*/
function satisfies(version: string, range: string, loose?: boolean): boolean;
/**
* Return the highest version in the list that satisfies the range, or null if none of them do.
*/
function maxSatisfying(versions: string[], range: string, loose?: boolean): string;
/**
* Return true if version is greater than all the versions possible in the range.
*/
function gtr(version: string, range: string, loose?: boolean): boolean;
/**
* Return true if version is less than all the versions possible in the range.
*/
function ltr(version: string, range: string, loose?: boolean): 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.)
*/
function outside(version: string, range: string, hilo: string, loose?: boolean): boolean;
class SemVerBase {
raw: string;
loose: boolean;
format(): string;
inspect(): string;
toString(): string;
}
class SemVer extends SemVerBase {
constructor(version: string, loose?: boolean);
major: number;
minor: number;
patch: number;
version: string;
build: string[];
prerelease: string[];
compare(other:SemVer): number;
compareMain(other:SemVer): number;
comparePre(other:SemVer): number;
inc(release: string): SemVer;
}
class Comparator extends SemVerBase {
constructor(comp: string, loose?: boolean);
semver: SemVer;
operator: string;
value: boolean;
parse(comp: string): void;
test(version:SemVer): boolean;
}
class Range extends SemVerBase {
constructor(range: string, loose?: boolean);
set: Comparator[][];
parseRange(range: string): Comparator[];
test(version: SemVer): boolean;
}
}
interface SemVerStatic {
SemVer(version: string, loose?: boolean): SemVerModule.SemVer;
Comparator(comp: string, loose?: boolean): SemVerModule.Comparator;
Range(range: string, loose?: boolean): SemVerModule.Range;
clean(version: string, loose?: boolean): string;
SEMVER_SPEC_VERSION: string;
valid(v: string, loose?: boolean): string;
inc(v: string, release: string, loose?: boolean): string;
major(v: string, loose?: boolean): number;
minor(v: string, loose?: boolean): number;
patch(v: string, loose?: boolean): number;
gt(v1: string, v2: string, loose?: boolean): boolean;
gte(v1: string, v2: string, loose?: boolean): boolean;
lt(v1: string, v2: string, loose?: boolean): boolean;
lte(v1: string, v2: string, loose?: boolean): boolean;
eq(v1: string, v2: string, loose?: boolean): boolean;
neq(v1: string, v2: string, loose?: boolean): boolean;
cmp(v1: string, comparator: any, v2: string, loose?: boolean): boolean;
compare(v1: string, v2: string, loose?: boolean): number;
rcompare(v1: string, v2: string, loose?: boolean): number;
diff(v1: string, v2: string, loose?: boolean): string;
validRange(range: string, loose?: boolean): string;
satisfies(version: string, range: string, loose?: boolean): boolean;
maxSatisfying(versions: string[], range: string, loose?: boolean): string;
gtr(version: string, range: string, loose?: boolean): boolean;
ltr(version: string, range: string, loose?: boolean): boolean;
outside(version: string, range: string, hilo: string, loose?: boolean): boolean;
}
declare var semver: SemVerStatic;
declare module "semver" {
export = SemVerModule;
}