Skip to main content

Function: uniqueConcur()

uniqueConcur<Value>(concurIterable): ConcurIterable<Value>

Returns a concur iterable containing the values of concurIterable in iteration order, except values are deduplicated if they are equal using Object.is.

Type Parameters

Value

Parameters

concurIterable

ConcurIterable<Value>

Returns

ConcurIterable<Value>

Example

import { asConcur, flatMapConcur, map, pipe, reduceConcur, toArray, uniqueConcur } from 'lfi'

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

console.log(
await pipe(
asConcur([`sloth`, `lazy`, `sleep`]),
flatMapConcur(async word => {
const response = await fetch(`${API_URL}/${word}`)
const [{ meanings }] = await response.json()
return map(meaning => meaning.partOfSpeech, meanings)
}),
uniqueConcur,
reduceConcur(toArray()),
),
)
// NOTE: This order may change between runs
//=> [ 'noun', 'verb', 'adjective' ]
Playground

Since

v0.0.2

Defined in

filters.d.ts:610