lazyrange
Example
; // for-of loopsfor let i of // 0, 1, 2, 3, 4 // array-like iteration;
API
Creation
; let foo = ;let bar = 5 0 -1;
new Range(end) -> Range
Creates a range starting at 0 and ending at end
using a step of 1
.
new Range(start, end, [step]) -> Range
Creates a range from start
to end
using a step
that defaults to 1
,
range( ... ) -> Range
Shortcut method to return a new instance of a range.
Methods
Range.prototype.toArray() -> Array
Evaluates the range into an array.
let arr = ;// [0, 1, 2, 3, 4]
Range.prototype.map(callback) -> Array
Maps the range to an array.
var arr = ;// [0, 1, 4, 9, 16]
Range.prototype.reduce(callback, memo) -> *
Reduces the range to a value.
var val = ;// 10
Range.prototype.each(callback) | Range.prototype.forEach(callback)
Iterates over each value in the range.
;
for-of
Lazily iterate over each value in the range.
for (let i of range(5)) {
}