Skip to main content

Function: uniqueByAsync()

Returns an async iterable containing the values of asyncIterable in iteration order, except values for which fn returns a value awaitable to the same value are deduplicated.

When values are deduplicated, the value earlier in iteration order wins.

Example

console.log(
await pipe(
asAsync([`sloth`, `sleep`, `fast`, `slow`, `mean`]),
uniqueByAsync(word => word.length),
reduceAsync(toArray()),
),
)
//=> [ 'sloth', 'fast' ]

uniqueByAsync(fn)

uniqueByAsync<Value>(fn): (asyncIterable) => AsyncIterable<Value, any, any>

Returns an async iterable containing the values of asyncIterable in iteration order, except values for which fn returns a value awaitable to the same value are deduplicated.

When values are deduplicated, the value earlier in iteration order wins.

Type Parameters

Value

Parameters

fn

Returns

Function

Parameters

asyncIterable: AsyncIterable<Value, any, any>

Returns

AsyncIterable<Value, any, any>

Example

console.log(
await pipe(
asAsync([`sloth`, `sleep`, `fast`, `slow`, `mean`]),
uniqueByAsync(word => word.length),
reduceAsync(toArray()),
),
)
//=> [ 'sloth', 'fast' ]

Defined in

filters.d.ts:359

uniqueByAsync(fn, asyncIterable)

uniqueByAsync<Value>(fn, asyncIterable): AsyncIterable<Value, any, any>

Returns an async iterable containing the values of asyncIterable in iteration order, except values for which fn returns a value awaitable to the same value are deduplicated.

When values are deduplicated, the value earlier in iteration order wins.

Type Parameters

Value

Parameters

fn

asyncIterable: AsyncIterable<Value, any, any>

Returns

AsyncIterable<Value, any, any>

Example

console.log(
await pipe(
asAsync([`sloth`, `sleep`, `fast`, `slow`, `mean`]),
uniqueByAsync(word => word.length),
reduceAsync(toArray()),
),
)
//=> [ 'sloth', 'fast' ]

Defined in

filters.d.ts:362