Skip to content

tap

tap<T>(iterable, onItem): IterableIterator<T>

Defined in: packages/core/src/iterable/tap.ts:17

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

How a lazy pipeline is instrumented: the side effect runs when an element is pulled, not when the pipeline is built, so nothing is observed that the consumer did not ask for.

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

T

Iterable<T>

The input iterable.

Callable<[T, number]>

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

IterableIterator<T>

An iterator over the unchanged elements.