SuperRangeObject
- class SuperRangeObject()
Defines a consistent interface for each of the range object types to inherit from, provides some array methods.
Methods
filter
- SuperRangeObject.filter(...args)
Converts range to an Array and then calls filter(…args) on it.
- Arguments:
args (any) – Same args as you would pass to Array#filter
Example
const rangeObject = new RangeObject(0, 10);
const filtered = rangeObject.filter((num) => num % 2 === 0);
// [ 0, 2, 4, 6, 8, 10 ]
slice
- SuperRangeObject.slice(start=0, end)
Generate array from range starting at value start and ending at value end via nthValue.
- Arguments:
start (number) – index to start slice
end (number) – index to end slice, return rest of array if not provided.
Example:
const rangeObject = new RangeObject(0, 10);
const sliced = rangeObject.slice(0, 5);
// [ 0, 1, 2, 3, 4 ]