Variable: takeAsync
const
takeAsync:SubAsync
Defined in: splices.d.ts:371
Returns an async iterable containing the first count
values of
asyncIterable
in iteration order.
If the count
is greater than the number of values in asyncIterable
, then
an async iterable equivalent asyncIterable
is returned.
Throws
if count
isn't a non-negative integer.
import { asAsync, mapAsync, pipe, reduceAsync, takeAsync, toArray } from 'lfi'
const API_URL = `https://api.dictionaryapi.dev/api/v2/entries/en`
console.log(
await pipe(
asAsync([`sloth`, `lazy`, `sleep`, `active`, `awake`]),
mapAsync(async word => {
const response = await fetch(`${API_URL}/${word}`)
return (await response.json())[0].phonetic
}),
takeAsync(3),
reduceAsync(toArray()),
),
)
//=> [ '/slɑθ/', '/ˈleɪzi/', '/sliːp/' ]
Since
v0.0.1