* Returns a new array with all sub-array elements concatenated. * (more efficient than native flat) * * @param list * @returns
(list: T & L.List<I>)
| 17 | * @returns |
| 18 | */ |
| 19 | function flatten<T extends L.List, I>(list: T & L.List<I>): Flatten<T> { |
| 20 | return reduce(list, (acc, item) => concat(acc, wrap(item)), [] as any[]) |
| 21 | } |
| 22 | |
| 23 | type Flatten<L extends L.List, I = L[number]> = (I extends L.List ? I[number] : I)[] |
| 24 |
no test coverage detected