forEachStep()
Performs the specified action for each step in the maximum range of an `Array`
Range.prototype.forEachStep()
Range.prototype.forEachStep()
The forEachStep()
method performs the specified action for each step in the maximum range of an Array
.
public forEachStep(
forEachStep: (value: number, step: number, range: readonly number[]) => void
): this {
this.range.forEach(forEachStep);
return this;
}
Parameters
forEachStep: (value:
number
, step:
number
, range: readonly
number
[]) => void
forEachStep: (value:
number
, step:
number
, range: readonly
number
[]) => void
A function that accepts up to three arguments. It's called one time for each step in the range.
Return type
Returns
The return value is the Range
instance.
Example usage
Maximum range
// Example usage.
import { Range } from '@angular-package/range';
// Create new instance.
// Returns Range {min: 3, max: 9} of Range<3, 9, 3>.
const range = new Range(3, 9, undefined, 3);
range.forEachStep((value, step, r) => {
// 4 - 5.5 - 7 - 8.5 - 10
value;
// 0 - 1 - 2 - 3 - 4
step;
// (5) [4, 5.5, 7, 8.5, 10]
r;
});
Last updated