Function tap

  • Tap into a value before calling a function.

    Example

    const log = tap(console.log);
    const double = (value: number) => value * 2;
    const doubleAndLog = log(double);

    doubleAndLog(2); // 4 (returns and logs 4)

    Returns

    Curried function with tapper in context.

    Type Parameters

    • Input

    Parameters

    • tapper: Unary<Input, unknown>

      Tapper function to be called with the value.

    Returns (<Tapped>(tapped: Tapped) => Tapped)

      • <Tapped>(tapped: Tapped): Tapped
      • Type Parameters

        • Tapped extends Unary<Input, unknown>

        Parameters

        • tapped: Tapped

        Returns Tapped