forked from microsoft/TypeScript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathes2019.array.d.ts
63 lines (57 loc) · 2.36 KB
/
es2019.array.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
type Flatten<T> = T extends undefined ? T : T extends readonly (infer U)[] ? U : T;
interface ReadonlyArray<T> {
/**
* Calls a defined callback function on each element of an array. Then, flattens the result into
* a new array.
* This is identical to a map followed by flat with depth 1.
*
* @param callback A function that accepts up to three arguments. The flatMap method calls the
* callback function one time for each element in the array.
* @param thisArg An object to which the this keyword can refer in the callback function. If
* thisArg is omitted, undefined is used as the this value.
*/
flatMap<U> (
callbackfn: (value: T, index: number, array: readonly T[]) => U,
thisArg?: any
): Flatten<U>[];
/**
* Returns a new array with all sub-array elements concatenated into it recursively up to the
* specified depth.
*
* @param depth The maximum recursion depth
*/
flat(depth: 4): Flatten<Flatten<Flatten<Flatten<T>>>>[];
flat(depth: 3): Flatten<Flatten<Flatten<T>>>[];
flat(depth: 2): Flatten<Flatten<T>>[];
flat(depth?: 1): Flatten<T>[];
flat(depth: 0): T[];
flat(depth: number): any[];
}
interface Array<T> {
/**
* Calls a defined callback function on each element of an array. Then, flattens the result into
* a new array.
* This is identical to a map followed by flat with depth 1.
*
* @param callback A function that accepts up to three arguments. The flatMap method calls the
* callback function one time for each element in the array.
* @param thisArg An object to which the this keyword can refer in the callback function. If
* thisArg is omitted, undefined is used as the this value.
*/
flatMap<U> (
callbackfn: (value: T, index: number, array: T[]) => U,
thisArg?: any
): Flatten<U>[];
/**
* Returns a new array with all sub-array elements concatenated into it recursively up to the
* specified depth.
*
* @param depth The maximum recursion depth
*/
flat(depth: 4): Flatten<Flatten<Flatten<Flatten<T>>>>[];
flat(depth: 3): Flatten<Flatten<Flatten<T>>>[];
flat(depth: 2): Flatten<Flatten<T>>[];
flat(depth?: 1): Flatten<T>[];
flat(depth: 0): T[];
flat(depth: number): any[];
}