1 | import { Concat } from './Concat';
|
2 | import { Append } from './Append';
|
3 | import { Cast } from '../Any/Cast';
|
4 | import { Length } from './Length';
|
5 | import { Iteration } from '../Iteration/Iteration';
|
6 | import { IterationOf } from '../Iteration/IterationOf';
|
7 | import { Next } from '../Iteration/Next';
|
8 | import { Pos } from '../Iteration/Pos';
|
9 | import { List } from './List';
|
10 | import { UnionOf } from './UnionOf';
|
11 | import { Naked } from './_Internal';
|
12 | import { Extends } from '../Any/Extends';
|
13 | import { Boolean } from '../Boolean/_Internal';
|
14 | import { Not } from '../Boolean/Not';
|
15 | import { And } from '../Boolean/And';
|
16 |
|
17 |
|
18 |
|
19 | declare type UnNestLoose<L extends List> = (UnionOf<L> extends infer UL ? UL extends unknown ? UL extends List ? UnionOf<UL> : UL : never : never)[] & {};
|
20 |
|
21 |
|
22 |
|
23 | declare type Flatter<L extends List, LN extends List, I extends Iteration> = L[Pos<I>] extends infer LP ? LP extends List ? Concat<LN, L[Pos<I>]> : Append<LN, L[Pos<I>]> : never;
|
24 |
|
25 |
|
26 |
|
27 | declare type UnNestStrict<L extends List, LN extends List = [], I extends Iteration = IterationOf<0>> = {
|
28 | 0: UnNestStrict<L, Flatter<L, LN, I>, Next<I>>;
|
29 | 1: LN;
|
30 | }[Extends<Pos<I>, Length<L>>];
|
31 |
|
32 |
|
33 |
|
34 | declare type __UnNest<L extends List, strict extends Boolean> = {
|
35 | 0: UnNestLoose<L>;
|
36 | 1: UnNestStrict<L>;
|
37 | }[And<Not<Extends<number, Length<L>>>, strict>];
|
38 |
|
39 |
|
40 |
|
41 | export declare type _UnNest<L extends List, strict extends Boolean> = __UnNest<Naked<L>, strict> extends infer X ? Cast<X, List> : never;
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 | export declare type UnNest<L extends List, strict extends Boolean = 1> = L extends unknown ? _UnNest<L, strict> : never;
|
52 | export {};
|