Skip to main content

Variable: flattenAsync()

const flattenAsync: <Value>(asyncIterable) => AsyncIterable<Value>

Defined in: transforms.d.ts:305

Returns an async iterable that contains the values of each iterable in asyncIterable in iteration order.

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

Type Parameters

Value

Value

Parameters

asyncIterable

AsyncIterable<Iterable<Value> | AsyncIterable<Value>>

Returns

AsyncIterable<Value>

Example

console.log(
await pipe(
asAsync([asAsync([1, 2]), [3, `sloth`, 5], asAsync([6, 7])]),
flattenAsync,
reduceAsync(toArray()),
),
)
//=> [ 1, 2, 3, 'sloth', 5, 6, 7 ]

Since

v0.0.1