Function linearSpace

  • Generates a step-length series of values between start and end (inclusive). Each value will be equally spaced.

    for (const v of linearSpace(1, 5, 6)) {
    // Yields: [ 1, 1.8, 2.6, 3.4, 4.2, 5 ]
    }

    Numbers can be produced from large to small as well

    const values = [...linearSpace(10, 5, 3)];
    // Yields: [10, 7.5, 5]

    Parameters

    • start: number

      Start number (inclusive)

    • end: number

      End number (inclusive)

    • steps: number

      How many steps to make from start -> end

    • Optionalprecision: number

      Number of decimal points to round to

    Returns IterableIterator<number>