Answers for "typescript range"

1

javascript range of integers with spread

// n is your max range
[...Array(n).keys()]

let n = 10
[...Array(n).keys()] // [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
Posted by: Guest on August-11-2020
0

typescript range

const range = (start, end) => Array.from({length: (end - start)}, (v, k) => k + start);
Posted by: Guest on August-24-2021
0

typescript type number range

type PrependNextNum<A extends Array<unknown>> = A['length'] extends infer T ? ((t: T, ...a: A) => void) extends ((...x: infer X) => void) ? X : never : never;

type EnumerateInternal<A extends Array<unknown>, N extends number> = { 0: A, 1: EnumerateInternal<PrependNextNum<A>, N> }[N extends A['length'] ? 0 : 1];

export type Enumerate<N extends number> = EnumerateInternal<[], N> extends (infer E)[] ? E : never;

export type Range<FROM extends number, TO extends number> = Exclude<Enumerate<TO>, Enumerate<FROM>>;
Posted by: Guest on December-16-2020

Code answers related to "TypeScript"

Browse Popular Code Answers by Language