UNPKG

1.3 kBTypeScriptView Raw
1import { List } from './List';
2import { _UnNest } from './UnNest';
3import { Cast } from '../Any/Cast';
4import { Equals } from '../Any/Equals';
5import { Iteration } from '../Iteration/Iteration';
6import { IterationOf } from '../Iteration/IterationOf';
7import { Extends } from '../Any/Extends';
8import { Next } from '../Iteration/Next';
9import { Or } from '../Boolean/Or';
10import { Boolean } from '../Boolean/_Internal';
11/**
12 * @hidden
13 */
14declare type __Flatten<L extends List, LO extends List, strict extends Boolean, limit extends Iteration, I extends Iteration = IterationOf<0>> = {
15 0: __Flatten<_UnNest<L, strict>, L, strict, limit, Next<I>>;
16 1: L;
17}[Or<Equals<L, LO>, Extends<limit, I>>];
18/**
19 * @hidden
20 */
21export declare type _Flatten<L extends List, strict extends Boolean, limit extends number = number> = __Flatten<L, [], strict, IterationOf<limit>> extends infer X ? Cast<X, List> : never;
22/**
23 * Remove all dimensions of `L` (10 max)
24 * @param L to un-nest
25 * @param strict (?=`1`) `0` to not preserve tuples
26 * @param limit (?=`string`) to stop un-nesting at
27 * @returns [[List]]
28 * @example
29 * ```ts
30 * ```
31 */
32export declare type Flatten<L extends List, strict extends Boolean = 1, limit extends number = number> = L extends unknown ? _Flatten<L, strict, limit> : never;
33export {};