Function: asAsync()
asAsync<
Value
>(iterable
):AsyncIterable
<Value
,any
,any
>
Returns an async iterable wrapper around iterable
.
WARNING: When passing a concur iterable the returned async iterable will 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.
Type Parameters
• Value
Parameters
iterable
Iterable
<Value
, any
, any
> | AsyncIterable
<Value
, any
, any
> | ConcurIterable
<Value
>
Returns
AsyncIterable
<Value
, any
, any
>
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
Since
v0.0.2