UNPKG

@monstermann/fn

Version:

A utility library for TypeScript.

26 lines (24 loc) 447 B
import { dfdlT } from "@monstermann/dfdl"; //#region src/function/tap.ts /** * `tap(fn)` * * Executes a function with the provided value and returns the original value unchanged. * * ```ts * tap(5, (x) => console.log(x)); // logs 5, returns 5 * ``` * * ```ts * pipe( * 5, * tap((x) => console.log(x)), * ); // logs 5, returns 5 * ``` */ const tap = dfdlT((target, fn) => { fn(target); return target; }, 2); //#endregion export { tap };