Skip to content

range

range(start, stop, step?): IterableIterator<number>

Defined in: packages/core/src/iterable/range.ts:23

Yields the arithmetic progression from start towards stop, exclusive.

Stands in for TC39’s Iterator.range, and follows it: start is required, stop is exclusive, and a stop of Infinity (or -Infinity with a negative step) yields forever. Nothing is materialised.

Each value is computed as start + step * index rather than accumulated, so a fractional step does not drift — range(0, 1, 0.1) ends at 0.9, not at 0.9999999999999999.

Time complexity: O(1) to construct, O(1) per value.

number

The first value, inclusive. Must be finite.

number

The bound to stop before, exclusive. May be infinite.

number = 1

How much to advance by. Must be finite and non-zero; a negative value counts down.

IterableIterator<number>

An iterator over the progression. Empty when stop is already on the far side of start.

If start is not finite, stop is NaN, or step is zero, NaN or infinite.