UNPKG

@lou.codes/iterables

Version:
21 lines (20 loc) 587 B
import type { Numeric } from "@lou.codes/types"; /** * Range iterable generator (from `from` to `to`). * * @category Generators * @example * ```typescript * [...range(1)(0)(5)]; // [0, 1, 2, 3, 4, 5] * [...range(1)(5)(0)]; // [5, 4, 3, 2, 1, 0] * ``` * @param step Step size. * @returns Curried function with `step` set in context. */ export declare const range: <Step extends Numeric>( step: Step, ) => ( from: Step extends bigint ? bigint : number, ) => ( to: Step extends bigint ? bigint : number, ) => Readonly<IterableIterator<Step extends bigint ? bigint : number>>;