Skip to main content

Function: mapAsync()

Returns an async iterable containing the values of asyncIterable transformed by fn in iteration order.

Like Array.prototype.map, but for async iterables.

Example

console.log(
await pipe(
asAsync([`sloth`, `more sloth`, `even more sloth`]),
mapAsync(string => string.length),
reduceAsync(toArray()),
),
)
//=> [ 5, 10, 15 ]

Since

v0.0.1

Call Signature

mapAsync<From, To>(fn): (asyncIterable) => AsyncIterable<To, any, any>

Type Parameters

From

To extends [] | unknown[]

Parameters

fn

(value) => MaybePromiseLike<To>

Returns

Function

Parameters

asyncIterable

AsyncIterable<From, any, any>

Returns

AsyncIterable<To, any, any>

Defined in

transforms.d.ts:64

Call Signature

mapAsync<From, To>(fn, asyncIterable): AsyncIterable<To, any, any>

Type Parameters

From

To extends [] | unknown[]

Parameters

fn

(value) => MaybePromiseLike<To>

asyncIterable

AsyncIterable<From, any, any>

Returns

AsyncIterable<To, any, any>

Defined in

transforms.d.ts:67

Call Signature

mapAsync<From, To>(fn): (asyncIterable) => AsyncIterable<To, any, any>

Type Parameters

From

To

Parameters

fn

(value) => MaybePromiseLike<To>

Returns

Function

Parameters

asyncIterable

AsyncIterable<From, any, any>

Returns

AsyncIterable<To, any, any>

Defined in

transforms.d.ts:72

Call Signature

mapAsync<From, To>(fn, asyncIterable): AsyncIterable<To, any, any>

Type Parameters

From

To

Parameters

fn

(value) => MaybePromiseLike<To>

asyncIterable

AsyncIterable<From, any, any>

Returns

AsyncIterable<To, any, any>

Defined in

transforms.d.ts:75