@iterables/map

a map function for iterables

Stats

StarsIssuesVersionUpdatedCreatedSize
@iterables/map
201.0.15 years ago5 years agoMinified + gzip package size for @iterables/map in KB

Readme

@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: any Iterator — a generator instance, Array, Map, String, or Set
  • fn: A function taking xs, idx, and all and returning any value.
    • xs: an item from iterable.
    • idx: a number reflecting the index of the current item.
    • all: the full iterable object.

Returns a mapped iterator. Pretty standard stuff!

License

MIT

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.