Function range

  • Type Parameters

    • T = number

    Parameters

    • startOrLength: number
    • Optionalend: number
    • valueOrMapper: T | ((i: number) => T) = ...
    • step: number = 1

    Returns Generator<T>

    Creates a generator that will produce an iteration through the range of number as requested.

    range(3)                  // yields 0, 1, 2, 3
    range(0, 3) // yields 0, 1, 2, 3
    range(0, 3, 'y') // yields y, y, y, y
    range(0, 3, () => 'y') // yields y, y, y, y
    range(0, 3, i => i) // yields 0, 1, 2, 3
    range(0, 3, i => `y${i}`) // yields y0, y1, y2, y3
    range(0, 3, obj) // yields obj, obj, obj, obj
    range(0, 6, i => i, 2) // yields 0, 2, 4, 6