functor-filter-arraylike-iterable
v0.1.2
Published
Iterable that implements optimized map & filter methods for array-like iterables
Downloads
1
Readme
functor-filter-arraylike-iterable
functor-filter-arraylike-iterable
exports a class that builds iterables that provide map method.
Install
$ npm install functor-filter-arraylike-iterable --save
Usage
const FunctorFilterArrayLikeIterable = require('functor-filter-arraylike-iterable')
const iterable = new FunctorFilterArrayLikeIterable([4, 2, 7, 8]) // (4 2 7 8)
.map(e => 3 * e) // (12 6 21 24)
.filter(e => e % 4 !== 1) // (12 6 24)
// converting to array:
[...iterable] // [12, 6, 24]
// traversing values:
for (const val of iterable) {
// ...
}
// creating an iterator that traverses the values
let iterator = iterable[Symbol.iterator]()
iterator.next() // {value: 12, done: false}
iterator.next() // {value: 6, done: false}
iterator.next() // {value: 24, done: false}
iterator.next() // {value: undefined, done: true}
Support
- Node.js >=6
- ES2015 transpilers
License
MIT