@wenzhi/mini-lodash
    Preparing search index...

    Function overArgs

    • 创建一个函数,调用func时参数为相对应的transforms的返回值。

      Parameters

      • func: Function

        要包裹的函数。

      • transforms: Function[]

        一个函数数组,每个函数的返回值将作为func的参数。

      Returns Function

      返回新函数。

      const func = (x: number, y: number) => [x, y]
      const add = (a: number) => a + 1
      const square = (a: number) => a * a
      const composedFunc = overArgs(func, [add, square])
      composedFunc(3, 4) // [4, 16]