Skip to main content

Variable: asAsync()

const asAsync: {<Value>(iterable): AsyncIterable<Awaited<Value>>; <Value, Size>(concurIterable, options?): AsyncIterable<Awaited<Value>>; }

Defined in: core.d.ts:269

Returns an async iterable wrapper around iterable.

WARNING: When passing a concur iterable the default behavior of the returned async iterable is to buffer the values yielded by the concur iterable if they are not read from the async iterable as quickly as they are yielded by the concur iterable. This happens because concur iterables are push-based while async iterables are pull-based, which creates backpressure. To customize how backpressure is applied, pass a BackpressureStrategy.

Call Signature

<Value>(iterable): AsyncIterable<Awaited<Value>>

Type Parameters

Value

Value

Parameters

iterable

Iterable<Value, any, any> | AsyncIterable<Value, any, any> | ConcurIterable<Value>

Returns

AsyncIterable<Awaited<Value>>

Call Signature

<Value, Size>(concurIterable, options?): AsyncIterable<Awaited<Value>>

Type Parameters

Value

Value

Size

Size extends number = number

Parameters

concurIterable

Iterable<Value, any, any> | AsyncIterable<Value, any, any> | ConcurIterable<Value>

options?

Readonly<{ backpressureStrategy?: BackpressureStrategy<Size>; }>

Returns

AsyncIterable<Awaited<Value>>

Example

import { asAsync } from 'lfi'

const asyncIterable = asAsync([`sloth`, `lazy`, `sleep`])

console.log(typeof asyncIterable[Symbol.asyncIterator])
//=> function

for await (const value of asyncIterable) {
console.log(value)
}
//=> sloth
//=> lazy
//=> sleep
Playground

Since

v0.0.2