Skip to content

filterMapAsync

filterMapAsync<T, R>(iterable, mapper): AsyncIterableIterator<R>

Defined in: packages/core/src/iterable/async/filter-map.ts:20

Maps and filters in one pass: yields every mapped value except the ones the mapper declines to produce.

The async counterpart of filterMap. undefined is the decline signal, and the result type cannot include it, so “no value here” is never confused with “the value is undefined”.

Time complexity: O(1) per element, plus whatever mapper costs.

T

R extends DefinedValue

MaybeAsyncIterable<T>

The input iterable, sync or async.

MaybeAsyncCallable<[T, number], R | undefined>

Receives each element and its zero-based index. Resolves to the mapped value, or undefined to drop the element.

AsyncIterableIterator<R>

An iterator over the produced values.