Tweakr
    Preparing search index...

    Function compose

    • Composes multiple functions from right to left.

      The result of each function is passed as input to the previous function.

      Parameters

      • ...fns: Function[]

        Functions to compose, applied from right to left.

      Returns (x: any) => any

      A function that represents the composition of the input functions.

      const add = (x: number) => x + 1;
      const double = (x: number) => x * 2;
      const composed = compose(double, add);
      console.log(composed(3)); // (3 + 1) * 2 = 8

      1.1.0