Invokes the specified action for each element while yielding the original elements unchanged.
Type of elements within source.
The source iterable.
Callback receiving the element and its zero-based index.
The original sequence, enabling fluent chaining.
The action executes lazily as the sequence is iterated, making it suitable for logging or instrumentation.
const numbers = [1, 2, 3];const tapped = tap(numbers, x => console.log(`Processing: ${x}`)) .select(x => x * 2) .toArray();console.log(tapped); // [2, 4, 6]// Expected console output:// Processing: 1// Processing: 2// Processing: 3 Copy
const numbers = [1, 2, 3];const tapped = tap(numbers, x => console.log(`Processing: ${x}`)) .select(x => x * 2) .toArray();console.log(tapped); // [2, 4, 6]// Expected console output:// Processing: 1// Processing: 2// Processing: 3
Invokes the specified action for each element while yielding the original elements unchanged.