Side-effect function to apply to each value
Configuration options
Optionalconcurrency?: numberNumber of concurrent operations (default: 1)
Optionalsignal?: AbortSignalAborting makes the transformer throw signal.reason and stop pulling from
the source; a call of f already in flight is left to settle on its own
A transformer function that yields the original values after applying the function
The tap function is used for side effects while processing an async iterable. It applies the provided function to each value but yields the original values unchanged. Supports concurrent processing with configurable concurrency.
// Log values as they pass through
const result = await G.pipe(
G.ofIterable([1, 2, 3, 4, 5]),
G.tap(value => console.log(`Processing: ${value}`)),
G.array
); // [1, 2, 3, 4, 5]
// Process values concurrently
const result = await G.pipe(
G.ofIterable([1, 2, 3, 4, 5]),
G.tap(async value => {
await longRunningOperation(value);
}, { concurrency: 3 }),
G.array
);
Creates a transformer that applies a function to each value without changing the values.