Variable: cycleAsync()
const
cycleAsync: <Value
>(asyncIterable
) =>AsyncIterable
<Value
>
Defined in: generators.d.ts:348
Returns an infinite async iterable that repeatedly yields the values of
asyncIterable
.
WARNING: This function does not buffer the values of asyncIterable
for
future cycles. It reiterates asyncIterable
each cycle.
Type Parameters
Value
Value
Parameters
asyncIterable
AsyncIterable
<Value
>
Returns
AsyncIterable
<Value
>
Example
import { asAsync, cycleAsync, joinAsync, mapAsync, pipe, takeAsync } from 'lfi'
const API_URL = `https://api.dictionaryapi.dev/api/v2/entries/en`
console.log(
await pipe(
asAsync([`sloth`, `lazy`, `sleep`]),
mapAsync(async word => {
const response = await fetch(`${API_URL}/${word}`)
return (await response.json())[0].phonetic
}),
cycleAsync,
takeAsync(6),
joinAsync(`, `),
),
)
//=> /slɑθ/, /ˈleɪzi/, /sliːp/, /slɑθ/, /ˈleɪzi/, /sliːp/
Since
v0.0.1