UNPKG

1.54 kBTypeScriptView Raw
1import { Tail } from './Tail';
2import { Cast } from '../Any/Cast';
3import { IterationOf } from '../Iteration/IterationOf';
4import { Iteration } from '../Iteration/Iteration';
5import { Way } from '../Iteration/_Internal';
6import { List } from './List';
7import { Pos } from '../Iteration/Pos';
8import { Prev } from '../Iteration/Prev';
9import { Prepend } from './Prepend';
10import { Naked } from './_Internal';
11import { Extends } from '../Any/Extends';
12/**
13 * @hidden
14 */
15declare type DropForth<L extends List, N extends Iteration> = {
16 0: DropForth<Tail<L>, Prev<N>>;
17 1: L;
18}[Extends<0, Pos<N>>];
19/**
20 * @hidden
21 */
22declare type DropBack<L extends List, N extends Iteration, I extends Iteration = Prev<N>, LN extends List = []> = {
23 0: DropBack<L, N, Prev<I>, Prepend<LN, L[Pos<I>]>>;
24 1: LN;
25}[Extends<-1, Pos<I>>];
26/**
27 * @hidden
28 */
29declare type __Drop<L extends List, N extends Iteration, way extends Way> = {
30 '->': DropForth<L, N>;
31 '<-': DropBack<L, N>;
32}[way];
33/**
34 * @hidden
35 */
36export declare type _Drop<L extends List, N extends number, way extends Way = '->'> = __Drop<Naked<L>, IterationOf<N>, way> extends infer X ? Cast<X, List> : never;
37/**
38 * Remove `N` entries out of `L`
39 * @param L to remove from
40 * @param N to remove out
41 * @param way (?=`'->'`) from front: '->', from end: '<-'
42 * @returns [[List]]
43 * @example
44 * ```ts
45 * ```
46 */
47export declare type Drop<L extends List, N extends number, way extends Way = '->'> = L extends unknown ? N extends unknown ? _Drop<L, N, way> : never : never;
48export {};