UNPKG

1.03 kBTypeScriptView Raw
1import { Prepend } from './Prepend';
2import { Pos } from '../Iteration/Pos';
3import { Next } from '../Iteration/Next';
4import { Length } from './Length';
5import { IterationOf } from '../Iteration/IterationOf';
6import { Iteration } from '../Iteration/Iteration';
7import { Cast } from '../Any/Cast';
8import { List } from './List';
9import { Naked } from './_Internal';
10import { Extends } from '../Any/Extends';
11/**
12 * @hidden
13 */
14declare type __Reverse<L extends List, LO extends List, I extends Iteration = IterationOf<0>> = {
15 0: __Reverse<L, Prepend<LO, L[Pos<I>]>, Next<I>>;
16 1: LO;
17}[Extends<Pos<I>, Length<L>>];
18/**
19 * @hidden
20 */
21export declare type _Reverse<L extends List, LO extends List = []> = __Reverse<Naked<L>, LO> extends infer X ? Cast<X, List> : never;
22/**
23 * Turn a [[List]] the other way around
24 * @param L to reverse
25 * @param LO (?=`[]`) to prepend to
26 * @returns [[List]]
27 * @example
28 * ```ts
29 * ```
30 */
31export declare type Reverse<L extends List> = L extends unknown ? _Reverse<L> : never;
32export {};