1 /*! *****************************************************************************
2 Copyright (c) Microsoft Corporation. All rights reserved.
3 Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4 this file except in compliance with the License. You may obtain a copy of the
5 License at http://www.apache.org/licenses/LICENSE-2.0
7 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
8 KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
9 WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
10 MERCHANTABLITY OR NON-INFRINGEMENT.
12 See the Apache Version 2.0 License for specific language governing permissions
13 and limitations under the License.
14 ***************************************************************************** */
18 /// <reference no-default-lib="true"/>
21 interface ReadonlyArray<T> {
24 * Calls a defined callback function on each element of an array. Then, flattens the result into
26 * This is identical to a map followed by flat with depth 1.
28 * @param callback A function that accepts up to three arguments. The flatMap method calls the
29 * callback function one time for each element in the array.
30 * @param thisArg An object to which the this keyword can refer in the callback function. If
31 * thisArg is omitted, undefined is used as the this value.
33 flatMap<U, This = undefined> (
34 callback: (this: This, value: T, index: number, array: T[]) => U|ReadonlyArray<U>,
40 * Returns a new array with all sub-array elements concatenated into it recursively up to the
43 * @param depth The maximum recursion depth
46 ReadonlyArray<U[][][][]> |
48 ReadonlyArray<ReadonlyArray<U[][][]>> |
49 ReadonlyArray<ReadonlyArray<U[][]>[]> |
50 ReadonlyArray<ReadonlyArray<U[]>[][]> |
51 ReadonlyArray<ReadonlyArray<U>[][][]> |
53 ReadonlyArray<ReadonlyArray<ReadonlyArray<U[][]>>> |
54 ReadonlyArray<ReadonlyArray<ReadonlyArray<U>[][]>> |
55 ReadonlyArray<ReadonlyArray<ReadonlyArray<U>>[][]> |
56 ReadonlyArray<ReadonlyArray<ReadonlyArray<U>[]>[]> |
57 ReadonlyArray<ReadonlyArray<ReadonlyArray<U[]>>[]> |
58 ReadonlyArray<ReadonlyArray<ReadonlyArray<U[]>[]>> |
60 ReadonlyArray<ReadonlyArray<ReadonlyArray<ReadonlyArray<U[]>>>> |
61 ReadonlyArray<ReadonlyArray<ReadonlyArray<ReadonlyArray<U>[]>>> |
62 ReadonlyArray<ReadonlyArray<ReadonlyArray<ReadonlyArray<U>>[]>> |
63 ReadonlyArray<ReadonlyArray<ReadonlyArray<ReadonlyArray<U>>>[]> |
65 ReadonlyArray<ReadonlyArray<ReadonlyArray<ReadonlyArray<ReadonlyArray<U>>>>>,
69 * Returns a new array with all sub-array elements concatenated into it recursively up to the
72 * @param depth The maximum recursion depth
75 ReadonlyArray<U[][][]> |
77 ReadonlyArray<ReadonlyArray<U>[][]> |
78 ReadonlyArray<ReadonlyArray<U[]>[]> |
79 ReadonlyArray<ReadonlyArray<U[][]>> |
81 ReadonlyArray<ReadonlyArray<ReadonlyArray<U[]>>> |
82 ReadonlyArray<ReadonlyArray<ReadonlyArray<U>[]>> |
83 ReadonlyArray<ReadonlyArray<ReadonlyArray<U>>[]> |
85 ReadonlyArray<ReadonlyArray<ReadonlyArray<ReadonlyArray<U>>>>,
89 * Returns a new array with all sub-array elements concatenated into it recursively up to the
92 * @param depth The maximum recursion depth
95 ReadonlyArray<U[][]> |
97 ReadonlyArray<ReadonlyArray<U[]>> |
98 ReadonlyArray<ReadonlyArray<U>[]> |
100 ReadonlyArray<ReadonlyArray<ReadonlyArray<U>>>,
104 * Returns a new array with all sub-array elements concatenated into it recursively up to the
107 * @param depth The maximum recursion depth
111 ReadonlyArray<ReadonlyArray<U>>,
116 * Returns a new array with all sub-array elements concatenated into it recursively up to the
119 * @param depth The maximum recursion depth
127 * Returns a new array with all sub-array elements concatenated into it recursively up to the
128 * specified depth. If no depth is provided, flat method defaults to the depth of 1.
130 * @param depth The maximum recursion depth
132 flat<U>(depth?: number): any[];
138 * Calls a defined callback function on each element of an array. Then, flattens the result into
140 * This is identical to a map followed by flat with depth 1.
142 * @param callback A function that accepts up to three arguments. The flatMap method calls the
143 * callback function one time for each element in the array.
144 * @param thisArg An object to which the this keyword can refer in the callback function. If
145 * thisArg is omitted, undefined is used as the this value.
147 flatMap<U, This = undefined> (
148 callback: (this: This, value: T, index: number, array: T[]) => U|ReadonlyArray<U>,
153 * Returns a new array with all sub-array elements concatenated into it recursively up to the
156 * @param depth The maximum recursion depth
158 flat<U>(this: U[][][][][][][][], depth: 7): U[];
161 * Returns a new array with all sub-array elements concatenated into it recursively up to the
164 * @param depth The maximum recursion depth
166 flat<U>(this: U[][][][][][][], depth: 6): U[];
169 * Returns a new array with all sub-array elements concatenated into it recursively up to the
172 * @param depth The maximum recursion depth
174 flat<U>(this: U[][][][][][], depth: 5): U[];
177 * Returns a new array with all sub-array elements concatenated into it recursively up to the
180 * @param depth The maximum recursion depth
182 flat<U>(this: U[][][][][], depth: 4): U[];
185 * Returns a new array with all sub-array elements concatenated into it recursively up to the
188 * @param depth The maximum recursion depth
190 flat<U>(this: U[][][][], depth: 3): U[];
193 * Returns a new array with all sub-array elements concatenated into it recursively up to the
196 * @param depth The maximum recursion depth
198 flat<U>(this: U[][][], depth: 2): U[];
201 * Returns a new array with all sub-array elements concatenated into it recursively up to the
204 * @param depth The maximum recursion depth
206 flat<U>(this: U[][], depth?: 1): U[];
209 * Returns a new array with all sub-array elements concatenated into it recursively up to the
212 * @param depth The maximum recursion depth
214 flat<U>(this: U[], depth: 0): U[];
217 * Returns a new array with all sub-array elements concatenated into it recursively up to the
218 * specified depth. If no depth is provided, flat method defaults to the depth of 1.
220 * @param depth The maximum recursion depth
222 flat<U>(depth?: number): any[];