Skip to main content

Variable: uniqueAsync()

const uniqueAsync: <Value>(asyncIterable) => AsyncIterable<Value>

Defined in: filters.d.ts:576

Returns an async iterable containing the values of asyncIterable in iteration order, except values are deduplicated if they are equal using Object.is.

Type Parameters

Value

Value

Parameters

asyncIterable

AsyncIterable<Value>

Returns

AsyncIterable<Value>

Example

import { asAsync, flatMapAsync, map, pipe, reduceAsync, toArray, uniqueAsync } from 'lfi'

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

console.log(
await pipe(
asAsync([`sloth`, `lazy`, `sleep`]),
flatMapAsync(async word => {
const response = await fetch(`${API_URL}/${word}`)
const [{ meanings }] = await response.json()
return map(meaning => meaning.partOfSpeech, meanings)
}),
uniqueAsync,
reduceAsync(toArray()),
),
)
//=> [ 'noun', 'verb', 'adjective' ]
Playground

Since

v0.0.2