Function: stepBy()
stepBy<
ElementType>(iterable:IterableResolvable<ElementType>,step:number):IterableIterator<ElementType>
Defined in: projects/utilities/packages/iterator-utilities/src/lib/stepBy.ts:25
Creates an iterator starting at the same point, but stepping by the given amount at each iteration.
Type Parameters
| Type Parameter | 
|---|
| ElementType | 
Parameters
| Parameter | Type | Description | 
|---|---|---|
| iterable | IterableResolvable<ElementType> | An iterator to map over. | 
| step | number | A positive integer representing the step to take at each iteration. | 
Returns
IterableIterator<ElementType>
Example
import { stepBy } from '@sapphire/iterator-utilities';
const iterable = [0, 1, 2, 3, 4, 5];
console.log([...stepBy(iterable, 2)]);
// Output: [0, 2, 4]
Remarks
The first element of the iterator will always be returned, regardless of the step given.