Referencerange
Reference · 03
range
range
Emits consecutive integers over a given range.
Signature
range(start: number, count?: number): Observable
Marble diagram
range(10, 3): (10 11 12 |)
What it does
Creates a stream of count numbers starting from start. It all happens synchronously and the stream completes. If count is omitted it defaults to Number.POSITIVE_INFINITY (don't run that in production without take).
When to use
When you need a predictable sequence of indices: iterating, batching by N, tests with deterministic values. Often combined with map to generate richer values from the index.
See also
of, generate, interval
script.ts
CONSOLE · Console output
Hit Run to see the result...