Function: consumeConcur()
consumeConcur(
concurIterable
):Promise
<void
>
Iterates through the concurIterable
causing lazy operations to run.
Parameters
concurIterable
ConcurIterable
<unknown
>
Returns
Promise
<void
>
Example
import { asConcur, consumeConcur, eachConcur, mapConcur, pipe } from 'lfi'
const API_URL = `https://api.dictionaryapi.dev/api/v2/entries/en`
const asyncIterable = pipe(
asConcur([`sloth`, `lazy`, `sleep`]),
mapConcur(async word => {
const response = await fetch(`${API_URL}/${word}`)
return (await response.json())[0].phonetic
}),
eachConcur(console.log),
)
// No output
await consumeConcur(asyncIterable)
// NOTE: This order may change between runs
//=> /slɑθ/
//=> /ˈleɪzi/
//=> /sliːp/
Since
v2.0.0