Function: range()
range(
start:number,end:number,step?:number):IterableIterator<number>
Defined in: projects/utilities/packages/iterator-utilities/src/lib/range.ts:33
Creates an iterable with the numbers from start to stop (exclusive) with an optional step.
Parameters
| Parameter | Type | Description | 
|---|---|---|
| start | number | The value of the first number in the range. | 
| end | number | The end value of the range. | 
| step? | number | The amount to increment the range by. | 
Returns
IterableIterator<number>
Examples
import { range } from '@sapphire/iterator-utilities';
const iterable = range(0, 5);
console.log([...iterable]);
// Output: [0, 1, 2, 3, 4]
const iterable = range(5, 0);
console.log([...iterable]);
// Output: [5, 4, 3, 2, 1]
const iterable = range(0, 5, 2);
console.log([...iterable]);
// Output: [0, 2, 4]