Skip to content

tapAsync

tapAsync<T>(iterable, onItem): AsyncIterableIterator<T>

Defined in: packages/core/src/iterable/async/tap.ts:18

Yields the elements unchanged, running onItem for each as it passes.

The async counterpart of tap. An async onItem is awaited before the element is yielded, so the side effect is ordered against the stream rather than racing it.

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

T

MaybeAsyncIterable<T>

The input iterable, sync or async.

MaybeAsyncCallable<[T, number]>

Receives each element and its zero-based index. Its resolved value is ignored.

AsyncIterableIterator<T>

An iterator over the unchanged elements.