Function tap

  • Applies a function sideEffect to the input, then returns the input. The primary use case for tap is debugging values in the middle of a pipe or flow chain.

    Example

    import { pipe, tap } from "flurp";
    import * as N from "flurp/number";

    pipe(
    5,
    N.multiply(2),
    tap(console.log), // prints 10 to the console, passes 10 on to the next function
    N.multiply(2)
    ); // 20

    Type Parameters

    • T

    Parameters

    • sideEffect: ((v: T) => unknown)
        • (v: T): unknown
        • Parameters

          • v: T

          Returns unknown

    Returns ((val: T) => T)

      • (val: T): T
      • Parameters

        • val: T

        Returns T