Skip to main content

Function: eachAsync()

Returns an async iterable equivalent to asyncIterable that applies fn to each value of asyncIterable as it is iterated.

The result of applying fn to a value is awaited before yielding and then moving on to the next value.

Example

const eachedSloths = await pipe(
asAsync([`carl`, `frank`, `phil`]),
eachAsync(console.log),
reduceAsync(toArray()),
)
//=> carl
//=> frank
//=> phil

console.log(eachedSloths)
//=> [ 'carl', 'frank', 'phil' ]

eachAsync(fn)

eachAsync<Value>(fn): (asyncIterable) => AsyncIterable<Value, any, any>

Returns an async iterable equivalent to asyncIterable that applies fn to each value of asyncIterable as it is iterated.

The result of applying fn to a value is awaited before yielding and then moving on to the next value.

Type Parameters

Value

Parameters

fn

Returns

Function

Parameters

asyncIterable: AsyncIterable<Value, any, any>

Returns

AsyncIterable<Value, any, any>

Example

const eachedSloths = await pipe(
asAsync([`carl`, `frank`, `phil`]),
eachAsync(console.log),
reduceAsync(toArray()),
)
//=> carl
//=> frank
//=> phil

console.log(eachedSloths)
//=> [ 'carl', 'frank', 'phil' ]

Defined in

side-effects.d.ts:64

eachAsync(fn, asyncIterable)

eachAsync<Value>(fn, asyncIterable): AsyncIterable<Value, any, any>

Returns an async iterable equivalent to asyncIterable that applies fn to each value of asyncIterable as it is iterated.

The result of applying fn to a value is awaited before yielding and then moving on to the next value.

Type Parameters

Value

Parameters

fn

asyncIterable: AsyncIterable<Value, any, any>

Returns

AsyncIterable<Value, any, any>

Example

const eachedSloths = await pipe(
asAsync([`carl`, `frank`, `phil`]),
eachAsync(console.log),
reduceAsync(toArray()),
)
//=> carl
//=> frank
//=> phil

console.log(eachedSloths)
//=> [ 'carl', 'frank', 'phil' ]

Defined in

side-effects.d.ts:67

eachAsync(fn)

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

Returns an async iterable equivalent to asyncIterable that applies fn to each value of asyncIterable as it is iterated.

The result of applying fn to a value is awaited before yielding and then moving on to the next value.

Type Parameters

From

To

Parameters

fn

Returns

Function

Parameters

asyncIterable: AsyncIterable<From, any, any>

Returns

AsyncIterable<To, any, any>

Example

const eachedSloths = await pipe(
asAsync([`carl`, `frank`, `phil`]),
eachAsync(console.log),
reduceAsync(toArray()),
)
//=> carl
//=> frank
//=> phil

console.log(eachedSloths)
//=> [ 'carl', 'frank', 'phil' ]

Defined in

side-effects.d.ts:72

eachAsync(fn, asyncIterable)

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

Returns an async iterable equivalent to asyncIterable that applies fn to each value of asyncIterable as it is iterated.

The result of applying fn to a value is awaited before yielding and then moving on to the next value.

Type Parameters

From

To

Parameters

fn

asyncIterable: AsyncIterable<From, any, any>

Returns

AsyncIterable<To, any, any>

Example

const eachedSloths = await pipe(
asAsync([`carl`, `frank`, `phil`]),
eachAsync(console.log),
reduceAsync(toArray()),
)
//=> carl
//=> frank
//=> phil

console.log(eachedSloths)
//=> [ 'carl', 'frank', 'phil' ]

Defined in

side-effects.d.ts:75