The type of elements in the source iterable.
The type of the optional state maintained by the callback.
A generator function that takes an iterable and yields the same elements while executing the callback.
// Log values while passing them through
G.pipe(
[1, 2, 3],
G.tap(x => console.log(x)),
G.array
) // [1, 2, 3] (with side effect: logs 1, 2, 3)
// Maintain a count while passing values through
G.pipe(
[1, 2, 3],
G.tap((x, i, sum = 0) => sum + x),
G.array
) // [1, 2, 3] (while calculating sum = 6 as state)
Creates a generator that yields the same values as the source iterable but allows side effects via a callback function. The callback can maintain state between iterations.