Skip to content

fx-flow v0.7.0 / pipe/lazy / toAsync

Function: toAsync()

toAsync<T>(args): AsyncIterableIterator<Awaited<T>>

Returns AsyncIterable, it is used when you want to handle Promise values inside Iterable.

Type parameters

T

Parameters

args: Iterable<T | Promise<T>>

Returns

AsyncIterableIterator<Awaited<T>>

Example

typescript
let res = 0
for await (const v of toAsync([Promise.resolve(1), Promise.resolve(2), 3])) {
  res += v
}
console.log(res) // 6

More examples

Source

packages/core/src/pipe/lazy/toAsync.ts:17

Released under the MIT License.