-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.d.ts
335 lines (233 loc) · 15 KB
/
index.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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
// TODO: Once TS 3.0 is released (and gets a bit more widespread), remove one
// of these slashes and enable this triple-slash directive.
//// <reference lib="es2015.iterable" />
/* tslint:disable */
declare global {
// Shut up the type checker before the next TS version
interface Iterable<T> {}
}
type Collectionish<T> = Iterable<T> | ArrayLike<T>
export interface FormatOptions {
[key: string]: any;
}
export interface PrettifyOptions {
depth: number;
}
export interface FormatPrettify {
(value: any, options: PrettifyOptions): string;
}
export class AssertionError extends Error {
name: "AssertionError";
expected: any;
actual: any;
constructor(message?: string, expected?: any, actual?: any);
}
export function format(message: string, args: FormatOptions, prettify?: FormatPrettify): string;
export function escape(message: string): string;
/**
* Perform a prototype-agnostic deep object match.
*/
export function matchLoose<T>(a: T, b: T): boolean;
/**
* Perform a prototype-aware deep object match.
*/
export function matchStrict<T>(a: T, b: T): boolean;
export interface InspectOptions {
showHidden?: boolean;
depth?: number;
colors?: boolean;
customInspect?: boolean;
}
export interface InspectStyles {
special: string;
number: string;
boolean: string;
undefined: string;
null: string;
string: string;
symbol: string;
date: string;
regexp: string;
}
// Note: this delegates to either `util-inspect` or Node's native
// `util.inspect`, based on the environment.
export const inspect: {
(object: any, options?: InspectOptions): string;
/** @deprecated in favor of the options object version */
(object: any, showHidden?: boolean, depth?: boolean, colors?: boolean): string;
colors: {[key: string]: [number, number]};
styles: InspectStyles;
};
// And now, for all the assertions.
export function assert(condition: boolean, message?: string, actual?: any, expected?: any): void;
export function fail(message: string, actual?: any, expected?: any): void;
export function failFormat(message: string, args: FormatOptions, prettify?: FormatPrettify): void;
export interface SetLike<T> { has(value: T): boolean; }
export interface MapLike<T, U> extends SetLike<T> { get(value: T): U; }
// Type tests
export function ok(value: any): void;
export function notOk(value: any): void;
// `undefined` is omitted because it's impossible for it to check. If you really
// mean to use it, just use `assert.equal(value, undefined)`.
type AssertType =
| "array" | "array-like" | "bigint" | "boolean" | "function" | "iterable"
| "number" | "object" | "reference" | "string" | "symbol"
| (new (...args: any[]) => any)
export function is(Type: AssertType, value: any): void;
export function not(Type: AssertType, value: any): void;
export function possibly(Type: AssertType, value: any): void;
export function notPossibly(Type: AssertType, value: any): void;
// Numeric tests
export function atLeast(n: number, limit: number): void;
export function atMost(n: number, limit: number): void;
export function above(n: number, limit: number): void;
export function below(n: number, limit: number): void;
export function between(n: number, lower: number, upper: number): void;
export function notBetween(n: number, lower: number, upper: number): void;
export function closeTo(actual: number, expected: number, epsilon?: number): void;
export function notCloseTo(actual: number, expected: number, epsilon?: number): void;
// Exception testing
export function throws(Type: AssertType, func: () => any): void;
export function throwsMatching(
matcher: ((error: Error) => boolean) | string | RegExp | object,
func: () => any
): void;
// Key existence in object/set/map
export function hasOwn<T extends object>(object: T, key: keyof T): void;
export function lacksOwn<T extends object>(object: T, key: keyof T): void;
export function hasIn<T extends object>(object: T, key: keyof T): void;
export function lacksIn<T extends object>(object: T, key: keyof T): void;
export function hasKey<T>(object: SetLike<T>, key: T): void;
export function lacksKey<T>(object: SetLike<T>, key: T): void;
// Value/property structural equality
export function equal<T>(actual: T, expected: T): void;
export function notEqual<T>(actual: T, expected: T): void;
export function equalsAny<T>(actual: T, expected: Collectionish<T>): void;
export function equalsNone<T>(actual: T, expected: Collectionish<T>): void;
export function hasOwn<T extends object>(object: T, key: keyof T, value: T[typeof key]): void;
export function lacksOwn<T extends object>(object: T, key: keyof T, value: T[typeof key]): void;
export function hasIn<T extends object>(object: T, key: keyof T, value: T[typeof key]): void;
export function lacksIn<T extends object>(object: T, key: keyof T, value: T[typeof key]): void;
export function hasKey<T, U>(object: MapLike<T, U>, key: T, value: U): void;
export function lacksKey<T, U>(object: MapLike<T, U>, key: T, value: U): void;
// Structural existence in collection
export function includes<T>(coll: Collectionish<T>, value: T): void;
export function excludes<T>(coll: Collectionish<T>, value: T): void;
export function includesAll<T>(coll: Collectionish<T>, values: Collectionish<T>): void;
export function excludesAll<T>(coll: Collectionish<T>, values: Collectionish<T>): void;
export function includesAny<T>(coll: Collectionish<T>, values: Collectionish<T>): void;
export function excludesAny<T>(coll: Collectionish<T>, values: Collectionish<T>): void;
// Multiple keys' structural existence in object
export function hasAllOwn<T extends object>(object: T, keys: Collectionish<keyof T>): void;
export function lacksAllOwn<T extends object>(object: T, keys: Collectionish<keyof T>): void;
export function hasAnyOwn<T extends object>(object: T, keys: Collectionish<keyof T>): void;
export function lacksAnyOwn<T extends object>(object: T, keys: Collectionish<keyof T>): void;
export function hasAllIn<T extends object>(object: T, keys: Collectionish<keyof T>): void;
export function lacksAllIn<T extends object>(object: T, keys: Collectionish<keyof T>): void;
export function hasAnyIn<T extends object>(object: T, keys: Collectionish<keyof T>): void;
export function lacksAnyIn<T extends object>(object: T, keys: Collectionish<keyof T>): void;
export function hasAllKeys<T>(object: SetLike<T>, keys: Collectionish<T>): void;
export function lacksAllKeys<T>(object: SetLike<T>, keys: Collectionish<T>): void;
export function hasAnyKey<T>(object: SetLike<T>, keys: Collectionish<T>): void;
export function lacksAnyKey<T>(object: SetLike<T>, keys: Collectionish<T>): void;
// Multiple values' structural existence in object
export function hasAllOwn<T extends object>(object: T, keys: Partial<T>): void;
export function lacksAllOwn<T extends object>(object: T, keys: Partial<T>): void;
export function hasAnyOwn<T extends object>(object: T, keys: Partial<T>): void;
export function lacksAnyOwn<T extends object>(object: T, keys: Partial<T>): void;
export function hasAllIn<T extends object>(object: T, keys: Partial<T>): void;
export function lacksAllIn<T extends object>(object: T, keys: Partial<T>): void;
export function hasAnyIn<T extends object>(object: T, keys: Partial<T>): void;
export function lacksAnyIn<T extends object>(object: T, keys: Partial<T>): void;
export function hasAllKeys<K extends string | symbol, V>(object: MapLike<K, V>, keys: {[P in K]: V}): void;
export function lacksAllKeys<K extends string | symbol, V>(object: MapLike<K, V>, keys: {[P in K]: V}): void;
export function hasAnyKey<K extends string | symbol, V>(object: MapLike<K, V>, keys: {[P in K]: V}): void;
export function lacksAnyKey<K extends string | symbol, V>(object: MapLike<K, V>, keys: {[P in K]: V}): void;
// Value/property exact equality
export function exactlyEqual<T>(actual: T, expected: T): void;
export function exactlyNotEqual<T>(actual: T, expected: T): void;
export function exactlyEqualsAny<T>(actual: T, expected: Collectionish<T>): void;
export function exactlyEqualsNone<T>(actual: T, expected: Collectionish<T>): void;
export function exactlyHasOwn<T extends object>(object: T, key: keyof T, value: T[typeof key]): void;
export function exactlyLacksOwn<T extends object>(object: T, key: keyof T, value: T[typeof key]): void;
export function exactlyHasIn<T extends object>(object: T, key: keyof T, value: T[typeof key]): void;
export function exactlyLacksIn<T extends object>(object: T, key: keyof T, value: T[typeof key]): void;
export function exactlyHasKey<T, U>(object: MapLike<T, U>, key: T, value: U): void;
export function exactlyLacksKey<T, U>(object: MapLike<T, U>, key: T, value: U): void;
// Exact existence in collection
export function exactlyIncludes<T>(coll: Collectionish<T>, value: T): void;
export function exactlyExcludes<T>(coll: Collectionish<T>, value: T): void;
export function exactlyIncludesAll<T>(coll: Collectionish<T>, values: Collectionish<T>): void;
export function exactlyExcludesAll<T>(coll: Collectionish<T>, values: Collectionish<T>): void;
export function exactlyIncludesAny<T>(coll: Collectionish<T>, values: Collectionish<T>): void;
export function exactlyExcludesAny<T>(coll: Collectionish<T>, values: Collectionish<T>): void;
// Multiple keys' exact existence in object
export function exactlyHasAllIn<T extends object>(object: T, keys: Collectionish<keyof T>): void;
export function exactlyLacksAllIn<T extends object>(object: T, keys: Collectionish<keyof T>): void;
export function exactlyHasAnyIn<T extends object>(object: T, keys: Collectionish<keyof T>): void;
export function exactlyLacksAnyIn<T extends object>(object: T, keys: Collectionish<keyof T>): void;
export function exactlyHasAllOwn<T extends object>(object: T, keys: Collectionish<keyof T>): void;
export function exactlyLacksAllOwn<T extends object>(object: T, keys: Collectionish<keyof T>): void;
export function exactlyHasAnyOwn<T extends object>(object: T, keys: Collectionish<keyof T>): void;
export function exactlyLacksAnyOwn<T extends object>(object: T, keys: Collectionish<keyof T>): void;
export function exactlyHasAllKeys<K>(object: SetLike<K>, keys: Collectionish<K>): void;
export function exactlyLacksAllKeys<K>(object: SetLike<K>, keys: Collectionish<K>): void;
export function exactlyHasAnyKey<K>(object: SetLike<K>, keys: Collectionish<K>): void;
export function exactlyLacksAnyKey<K>(object: SetLike<K>, keys: Collectionish<K>): void;
// Multiple values' exact existence in object
export function exactlyHasAllIn<T>(object: T, keys: Partial<T>): void;
export function exactlyLacksAllIn<T>(object: T, keys: Partial<T>): void;
export function exactlyHasAnyIn<T>(object: T, keys: Partial<T>): void;
export function exactlyLacksAnyIn<T>(object: T, keys: Partial<T>): void;
export function exactlyHasAllOwn<T>(object: T, keys: Partial<T>): void;
export function exactlyLacksAllOwn<T>(object: T, keys: Partial<T>): void;
export function exactlyHasAnyOwn<T>(object: T, keys: Partial<T>): void;
export function exactlyLacksAnyOwn<T>(object: T, keys: Partial<T>): void;
export function exactlyHasAllKeys<K extends string | symbol, V>(object: MapLike<K, V>, keys: {[P in K]: V}): void;
export function exactlyLacksAllKeys<K extends string | symbol, V>(object: MapLike<K, V>, keys: {[P in K]: V}): void;
export function exactlyHasAnyKey<K extends string | symbol, V>(object: MapLike<K, V>, keys: {[P in K]: V}): void;
export function exactlyLacksAnyKey<K extends string | symbol, V>(object: MapLike<K, V>, keys: {[P in K]: V}): void;
// Value/property deep equality
export function deeplyEqual<T>(actual: T, expected: T): void;
export function deeplyNotEqual<T>(actual: T, expected: T): void;
export function deeplyEqualsAny<T>(actual: T, expected: Collectionish<T>): void;
export function deeplyEqualsNone<T>(actual: T, expected: Collectionish<T>): void;
export function deeplyHasOwn<T extends object>(object: T, key: keyof T, value: T[typeof key]): void;
export function deeplyLacksOwn<T extends object>(object: T, key: keyof T, value: T[typeof key]): void;
export function deeplyHasIn<T extends object>(object: T, key: keyof T, value: T[typeof key]): void;
export function deeplyLacksIn<T extends object>(object: T, key: keyof T, value: T[typeof key]): void;
export function deeplyHasKey<T, U>(object: MapLike<T, U>, key: T, value: U): void;
export function deeplyLacksKey<T, U>(object: MapLike<T, U>, key: T, value: U): void;
// Deep existence in collection
export function deeplyIncludes<T>(coll: Collectionish<T>, value: T): void;
export function deeplyExcludes<T>(coll: Collectionish<T>, value: T): void;
export function deeplyIncludesAll<T>(coll: Collectionish<T>, values: Collectionish<T>): void;
export function deeplyExcludesAll<T>(coll: Collectionish<T>, values: Collectionish<T>): void;
export function deeplyIncludesAny<T>(coll: Collectionish<T>, values: Collectionish<T>): void;
export function deeplyExcludesAny<T>(coll: Collectionish<T>, values: Collectionish<T>): void;
// Multiple keys' deep existence in object
export function deeplyHasAllIn<T extends object>(object: T, keys: Collectionish<keyof T>): void;
export function deeplyLacksAllIn<T extends object>(object: T, keys: Collectionish<keyof T>): void;
export function deeplyHasAnyIn<T extends object>(object: T, keys: Collectionish<keyof T>): void;
export function deeplyLacksAnyIn<T extends object>(object: T, keys: Collectionish<keyof T>): void;
export function deeplyHasAllOwn<T extends object>(object: T, keys: Collectionish<keyof T>): void;
export function deeplyLacksAllOwn<T extends object>(object: T, keys: Collectionish<keyof T>): void;
export function deeplyHasAnyOwn<T extends object>(object: T, keys: Collectionish<keyof T>): void;
export function deeplyLacksAnyOwn<T extends object>(object: T, keys: Collectionish<keyof T>): void;
export function deeplyHasAllKeys<K>(object: SetLike<K>, keys: Collectionish<K>): void;
export function deeplyLacksAllKeys<K>(object: SetLike<K>, keys: Collectionish<K>): void;
export function deeplyHasAnyKey<K>(object: SetLike<K>, keys: Collectionish<K>): void;
export function deeplyLacksAnyKey<K>(object: SetLike<K>, keys: Collectionish<K>): void;
// Multiple values' deep existence in object
export function deeplyHasAllIn<T>(object: T, keys: Partial<T>): void;
export function deeplyLacksAllIn<T>(object: T, keys: Partial<T>): void;
export function deeplyHasAnyIn<T>(object: T, keys: Partial<T>): void;
export function deeplyLacksAnyIn<T>(object: T, keys: Partial<T>): void;
export function deeplyHasAllOwn<T>(object: T, keys: Partial<T>): void;
export function deeplyLacksAllOwn<T>(object: T, keys: Partial<T>): void;
export function deeplyHasAnyOwn<T>(object: T, keys: Partial<T>): void;
export function deeplyLacksAnyOwn<T>(object: T, keys: Partial<T>): void;
export function deeplyHasAllKeys<K extends string | symbol, V>(object: MapLike<K, V>, keys: {[P in K]: V}): void;
export function deeplyLacksAllKeys<K extends string | symbol, V>(object: MapLike<K, V>, keys: {[P in K]: V}): void;
export function deeplyHasAnyKey<K extends string | symbol, V>(object: MapLike<K, V>, keys: {[P in K]: V}): void;
export function deeplyLacksAnyKey<K extends string | symbol, V>(object: MapLike<K, V>, keys: {[P in K]: V}): void;