@pengzhanbo/utils - v3.9.0
    Preparing search index...

    Function pipe

    • pipe multiple functions, left to right

      组合多个函数,从左到右执行

      Type Parameters

      • T extends Fn[] = Fn[]

        The type of elements in the array / 数组元素的类型

      Parameters

      • ...fns: T

        The functions to pipe. 要组合的函数

      Returns (...args: Parameters<FirstArray<T>>) => ReturnType<LastArray<T>>

      A new function that is the pipeline of the input functions. 由输入函数组合而成的新函数

      const add = (a) => a + 1
      const subtract = (a) => a - 2
      const multiply = (a, b) => a * b
      pipe(add, subtract, multiply)(1, 2) // => (1 * 2) + 1 - 2 = 1