Skip to main content

Variable: takeConcur

const takeConcur: SubConcur

Defined in: splices.d.ts:404

Returns a concur iterable containing the first count values of concurIterable in iteration order.

If the count is greater than the number of values in concurIterable, then a concur iterable equivalent concurIterable is returned.

Throws

if count isn't a non-negative integer.

import { asConcur, mapConcur, pipe, reduceConcur, takeConcur, toArray } from 'lfi'

const API_URL = `https://api.dictionaryapi.dev/api/v2/entries/en`

console.log(
await pipe(
asConcur([`sloth`, `lazy`, `sleep`, `active`, `awake`]),
mapConcur(async word => {
const response = await fetch(`${API_URL}/${word}`)
return (await response.json())[0].phonetic
}),
takeConcur(3),
reduceConcur(toArray()),
),
)
//=> [ '/slɑθ/', '/ˈleɪzi/', '/sliːp/' ]
Playground

Since

v0.0.2