Function: flatMap()
Returns an iterable containing the values of the iterables returned from
applying fn
to each value of iterable
in iteration order.
Like Array.prototype.flatMap
, but for iterables.
Example
console.log(
pipe(
[`sloth`, `more sloth`, `even more sloth`],
flatMap(string => [string, string.length]),
reduce(toArray()),
),
)
//=> [ 'sloth', 5, 'more sloth', 10, 'even more sloth', 15 ]
Since
v0.0.1
Call Signature
flatMap<
From
,To
>(fn
): (iterable
) =>Iterable
<To
,any
,any
>
Type Parameters
• From
• To extends [] | unknown
[]
Parameters
fn
(value
) => Iterable
<To
, any
, any
>
Returns
Function
Parameters
iterable
Iterable
<From
, any
, any
>
Returns
Iterable
<To
, any
, any
>
Defined in
Call Signature
flatMap<
From
,To
>(fn
,iterable
):Iterable
<To
,any
,any
>
Type Parameters
• From
• To extends [] | unknown
[]
Parameters
fn
(value
) => Iterable
<To
, any
, any
>
iterable
Iterable
<From
, any
, any
>
Returns
Iterable
<To
, any
, any
>
Defined in
Call Signature
flatMap<
From
,To
>(fn
): (iterable
) =>Iterable
<To
,any
,any
>
Type Parameters
• From
• To
Parameters
fn
(value
) => Iterable
<To
, any
, any
>
Returns
Function
Parameters
iterable
Iterable
<From
, any
, any
>
Returns
Iterable
<To
, any
, any
>
Defined in
Call Signature
flatMap<
From
,To
>(fn
,iterable
):Iterable
<To
,any
,any
>
Type Parameters
• From
• To
Parameters
fn
(value
) => Iterable
<To
, any
, any
>
iterable
Iterable
<From
, any
, any
>
Returns
Iterable
<To
, any
, any
>