Lazy method chaining iterables
This library exports a function to create a lazy iterable from any iterable. The return value's type will depend on what operations the original iterable supports:
- A
ContiguousRange
for anyTypedArray
- A
RandomAccessRange
for any iterable not above implementing a constant-time.at(index)
method - A
ForwardRange
for any iterable not above that can be iterated without consuming the input - An
InputRange
for any other iterable not above
A BidirectionalRange
may be returned by some of the lazy methods for ContiguousRange
, RandomAccessRange
, and itself, to indicate the returned iterable supports lazy .toReversed()
without buffering.
.drop(count: number)
.entries()
.filter(predicate: (value, index) => boolean)
.flatMap(callback: (value, index) => iterable)
.map(callback: (value, index) => any)
.scan(callback: (previous, value, index) => next, initial?)
.slice(begin?, end?)
.take(count: number)
.toReversed()
.toSorted(compare?: (a, b) => number)
.at(index: number): value?
.every(predicate: (value, index) => boolean): boolean
.find(predicate: (value, index) => boolean): value?
.findIndex(predicate: (value, index) => boolean): number
.findLast(predicate: (value, index) => boolean): value?
.findLastIndex(predicate: (value, index) => boolean): number
.first(predicate?: (value, index) => boolean): value?
.forEach(callback: (value, index) => void): void
.includes(value, fromIndex?: number): boolean
.indexOf(value, fromIndex?: number): number
.last(predicate?: (value, index) => boolean): value?
.lastIndexOf(value, fromIndex?: number): number
.reduce(callback: (previous, value, index) => next, initial?)
.some(predicate: (value, index) => boolean): boolean
.toArray(): array
...and more to come!
- Tests (and bugfixes)
- More documentation
- More methods