Skip to main content

range

Callable

  • range(start: number, stop?: number, step?: number): Generator<number, void, unknown>

  • Creates a generator of numbers from start to exclusive end. If the end end is not specified, the start will be interpreted as end, and the start will be set to 0.

    Example

    collect(range(5))
    // => [0, 1, 2, 3, 4]

    collect(range(0, 20, 5))
    // => [0, 5, 10, 15]

    for (const x of range(3)) {
    x // ?
    }
    // => 0, 1, 2

    Alternatives


    Parameters

    • start: number
    • optionalstop: number

      The end of the range (exclusive).

    • step: number = 1

    Returns Generator<number, void, unknown>

    The range generator.