Function numericRange

Generates a range of numbers, with a given interval.

let loopForever = numericRange(0.1); // By default starts at 0 and counts upwards forever
for (v of loopForever) {
console.log(v);
}
let percent = numericRange(0.1, 0, 1);

let percentResult = percent.next().value;

Note that computations are internally rounded to avoid floating point math issues. So if the interval is very small (eg thousandths), specify a higher rounding number.

  • Parameters

    • interval: number

      Interval between numbers

    • start: number = 0

      Start. Defaults to 0

    • Optionalend: number

      End (if undefined, range never ends)

    • repeating: boolean = false

      Range loops from start indefinately. Default false

    • Optionalrounding: number

      A rounding that matches the interval avoids floating-point math hikinks. Eg if the interval is 0.1, use a rounding of 10

    Returns Generator<number, void, unknown>