1.0.1 • Published 7 years ago
@iterables/map v1.0.1
@iterables/map
A map generator for iterators.
const map = require('@iterables/map')
const iter = map(function * () {
yield 1
yield 2
}(), xs => xs * 2)
console.log([...iter]) // [2, 4]
Installation
$ npm install --save @iterables/map
API
map(iterable, fn) -> Iterator
iterable
: anyIterator
— a generator instance,Array
,Map
,String
, orSet
fn
: A function takingxs
,idx
, andall
and returning any value.xs
: an item fromiterable
.idx
: a number reflecting the index of the current item.all
: the fulliterable
object.
Returns a mapped iterator. Pretty standard stuff!
License
MIT
1.0.1
7 years ago