package
Array.prototype.map analog for iterables.
npm install map-iterableGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
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.
You can omit the data argument and you get a function that map over the provided function.
npm install --save map-iterableconst map = require("map-iterable");
const numbers = [1, 4, 9];
const roots = Array.from(map(Math.sqrt, numbers));
// roots is now [1, 2, 3], numbers is still [1, 4, 9]using partial apply
const map = require("map-iterable");
const mapSqrt = map(Math.sqrt);
const numbers = [1, 4, 9];
cons;
const roots = Array.from(mapSqrt(numbers));
// roots is now [1, 2, 3], numbers is still [1, 4, 9]Creates a new iterable with the results of calling transform function on every
element in data iterable. If you omit the data argument return a unary
function that accept the data argument and map over the provided function.
Parameters
transform
Function
a function that return an element of the new Iterable, receiving as arguments:
. currentValue - The current element being processed in the iterable. index -
The index of the current element being processed in the iterable.data Iterable The source iterable to iterate over.Returns Iterable A new Iterable over results of the transform function.
The MIT License (MIT)
© 2017 Andrea Parodi
Estimated unpacked size across 2 packages.
2.2 kB
Includes dependencies.