A function that displays the content of a variable or function return on the console without compromising the flow.
Javascript:
function tap(x, fn) {
console.log(fn(x));
return x;
}
Typescript:
function tap<T>(x: T, fn: (x: T) => unknown = (x) => x): T {
console.log(fn(x));
return x;
}