Skip to main content

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 ]

Since

v0.0.1

Call Signature

map<From, To>(fn): (iterable) => Iterable<To, any, any>

Type Parameters

From

To extends [] | unknown[]

Parameters

fn

(value) => To

Returns

Function

Parameters

iterable

Iterable<From, any, any>

Returns

Iterable<To, any, any>

Defined in

transforms.d.ts:27

Call Signature

map<From, To>(fn, iterable): Iterable<To, any, any>

Type Parameters

From

To extends [] | unknown[]

Parameters

fn

(value) => To

iterable

Iterable<From, any, any>

Returns

Iterable<To, any, any>

Defined in

transforms.d.ts:30

Call Signature

map<From, To>(fn): (iterable) => Iterable<To, any, any>

Type Parameters

From

To

Parameters

fn

(value) => To

Returns

Function

Parameters

iterable

Iterable<From, any, any>

Returns

Iterable<To, any, any>

Defined in

transforms.d.ts:35

Call Signature

map<From, To>(fn, iterable): Iterable<To, any, any>

Type Parameters

From

To

Parameters

fn

(value) => To

iterable

Iterable<From, any, any>

Returns

Iterable<To, any, any>

Defined in

transforms.d.ts:38