Function: map()
Returns an iterable containing the values of iterable
transformed by fn
in iteration order.
Like Array.prototype.map
, but for iterables.
Example
console.log(
pipe(
[`sloth`, `more sloth`, `even more sloth`],
map(string => string.length),
reduce(toArray()),
),
)
//=> [ 5, 10, 15 ]
map(fn)
map<
From
,To
>(fn
): (iterable
) =>Iterable
<To
,any
,any
>
Returns an iterable containing the values of iterable
transformed by fn
in iteration order.
Like Array.prototype.map
, but for iterables.
Type Parameters
• From
• To
Parameters
• fn
Returns
Function
Parameters
• iterable: Iterable
<From
, any
, any
>
Returns
Iterable
<To
, any
, any
>
Example
console.log(
pipe(
[`sloth`, `more sloth`, `even more sloth`],
map(string => string.length),
reduce(toArray()),
),
)
//=> [ 5, 10, 15 ]
Defined in
map(fn, iterable)
map<
From
,To
>(fn
,iterable
):Iterable
<To
,any
,any
>
Returns an iterable containing the values of iterable
transformed by fn
in iteration order.
Like Array.prototype.map
, but for iterables.
Type Parameters
• From
• To
Parameters
• fn
• iterable: Iterable
<From
, any
, any
>
Returns
Iterable
<To
, any
, any
>
Example
console.log(
pipe(
[`sloth`, `more sloth`, `even more sloth`],
map(string => string.length),
reduce(toArray()),
),
)
//=> [ 5, 10, 15 ]