1 | import { IterationOf } from '../Iteration/IterationOf';
|
2 | import { Iteration } from '../Iteration/Iteration';
|
3 | import { Pos } from '../Iteration/Pos';
|
4 | import { Prepend } from './Prepend';
|
5 | import { Way } from '../Iteration/_Internal';
|
6 | import { List } from './List';
|
7 | import { Prev } from '../Iteration/Prev';
|
8 | import { Cast } from '../Any/Cast';
|
9 | import { Tail } from './Tail';
|
10 | import { Extends } from '../Any/Extends';
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | declare type TakeForth<L extends List, N extends Iteration, I extends Iteration = Prev<N>, LN extends List = []> = {
|
16 | 0: TakeForth<L, N, Prev<I>, Prepend<LN, L[Pos<I>]>>;
|
17 | 1: LN;
|
18 | }[Extends<-1, Pos<I>>];
|
19 |
|
20 |
|
21 |
|
22 |
|
23 | declare type TakeBack<L extends List, N extends Iteration> = {
|
24 | 0: TakeBack<Tail<L>, Prev<N>>;
|
25 | 1: L;
|
26 | }[Extends<0, Pos<N>>];
|
27 |
|
28 |
|
29 |
|
30 | declare type __Take<L extends List, N extends Iteration, way extends Way> = {
|
31 | '->': TakeForth<L, N>;
|
32 | '<-': TakeBack<L, N>;
|
33 | }[way];
|
34 |
|
35 |
|
36 |
|
37 | export declare type _Take<L extends List, N extends number, way extends Way = '->'> = __Take<L, IterationOf<N>, way> extends infer X ? Cast<X, List> : never;
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 | export declare type Take<L extends List, N extends number, way extends Way = '->'> = L extends unknown ? N extends unknown ? _Take<L, N, way> : never : never;
|
49 | export {};
|