Array.prototype.map analog for iterables.
The map() method creates a new iterable with the results of calling a provided function on every element in given iterable.
The function is curried, so you can omit the data argument and you get a function that map over the provide function.
npm install --save map-iterable
const map = ;const numbers = 1 4 9;const roots = Array;// roots is now [1, 2, 3], numbers is still [1, 4, 9]
const map = ;const mapSqrt = ;const numbers = 1 4 9;consconst roots = Array// roots is now [1, 2, 3], numbers is still [1, 4, 9]
If a function is provided, it shall be the callback that produces an element of the new Iterable, taking three arguments: - currentValue - The current element being processed in the iterable. - index - The index of the current element being processed in the iterable. - context - an object shared between all calls to the function.
If an object is provided, it is interpreted as on option object with following properties:
* callback: Function - see above * init: Function - optional init function that must return the initial value for `context`. If it's not provided, the iterable itself will be used as `context` initial value.
The source iterable to iterate over.
A new array with each element being the result of the callback function.
The MIT License (MIT)
Copyright (c) 2016 Andrea Parodi