Function flow

  • Composes a function that returns the result of invoking the given functions with the this binding of the created function, where each successive invocation is supplied the return value of the previous.

    Parameters

    • Rest ...funcs: Function[]

      The functions to invoke.

      Rest

    Returns Function

    Returns the new composite function.

    Since

    5.18.0

    See

    flowRight

    Example

    function square(n) {
    return n * n
    }

    const addSquare = flow(add, square)
    addSquare(1, 2)
    // => 9