@s-libs/js-core
    Preparing search index...

    Function wrapFunction

    • Returns a new function to use in place of func that will call the provided hooks in addition to func. They are called in the following order:

      1. before
      2. around if provided, else original
      3. transform
      4. after
      const sum = (a: number, b: number) => a + b;
      const sumAndLog = wrapFunction(sum, {
      after: (result, a, b) => {
      console.log(a, '+', b, '=', result);
      },
      }
      const sumPlusOne = wrapFunction(sum, {
      transform: (result) => result + 1,
      });

      Type Parameters

      • A extends any[]
      • R
      • T

      Parameters

      • original: (this: T, ...args: A) => R
      • hooks: Hooks<A, R, T>

      Returns (this: T, ...args: A) => R