UNPKG

640 BTypeScriptView Raw
1import { IterationMap } from './Iteration';
2/**
3 * Transform a number into an [[Iteration]]
4 * (to use [[Prev]], [[Next]], & [[Pos]])
5 * @param N to transform
6 * @returns [[Iteration]]
7 * @example
8 * ```ts
9 * import {I} from 'ts-toolbelt'
10 *
11 * type i = I.IterationOf<0> // ["-1", "1", "0", 0, "0"]
12 *
13 * type next = I.Next<i> // ["0", "2", "1", 1, "+"]
14 * type prev = I.Prev<i> // ["-2", "0", "-1", -1, "-"]
15 *
16 * type nnext = I.Pos<next> // +1
17 * type nprev = I.Pos<prev> // -1
18 * ```
19 */
20export declare type IterationOf<N extends number> = `${N}` extends keyof IterationMap ? IterationMap[`${N}`] : IterationMap['__'];