Skip to main content

Function: eachConcur()

Returns an concur iterable equivalent to concurIterable that applies fn to each value of concurIterable as it is iterated.

The result of applying fn to a value is awaited before yielding.

Example

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

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

console.log(
await pipe(
asConcur([`sloth`, `lazy`, `sleep`]),
mapConcur(async word => {
const response = await fetch(`${API_URL}/${word}`)
return (await response.json())[0].phonetic
}),
eachConcur(console.log),
reduceConcur(toArray()),
),
)
// NOTE: This order may change between runs
//=> /slɑθ/
//=> /ˈleɪzi/
//=> /sliːp/
//=> [ '/slɑθ/', '/ˈleɪzi/', '/sliːp/' ]
Playground

Since

v0.0.1

Call Signature

eachConcur<Value>(fn): (concurIterable) => ConcurIterable<Value>

Type Parameters

Value

Parameters

fn

(value) => PromiseLike<unknown>

Returns

Function

Parameters

concurIterable

ConcurIterable<Value>

Returns

ConcurIterable<Value>

Defined in

side-effects.d.ts:131

Call Signature

eachConcur<Value>(fn, concurIterable): ConcurIterable<Value>

Type Parameters

Value

Parameters

fn

(value) => PromiseLike<unknown>

concurIterable

ConcurIterable<Value>

Returns

ConcurIterable<Value>

Defined in

side-effects.d.ts:134

Call Signature

eachConcur<From, To>(fn): (concurIterable) => ConcurIterable<To>

Type Parameters

From

To

Parameters

fn

(value) => asserts value is To

Returns

Function

Parameters

concurIterable

ConcurIterable<From>

Returns

ConcurIterable<To>

Defined in

side-effects.d.ts:139

Call Signature

eachConcur<From, To>(fn, concurIterable): ConcurIterable<To>

Type Parameters

From

To

Parameters

fn

(value) => asserts value is To

concurIterable

ConcurIterable<From>

Returns

ConcurIterable<To>

Defined in

side-effects.d.ts:142