Home

function: flow


flow(funcs: Array.): function

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.

Example(s):

function square(n) {
  return n * n
}

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

Params:

Name Type Attribute Description
funcs The functions to invoke.

Returns:

function

  {
    "comment": "/**\r\n * Composes a function that returns the result of invoking the given functions\r\n * with the `this` binding of the created function, where each successive\r\n * invocation is supplied the return value of the previous.\r\n *\r\n * @since 3.0.0\r\n * @category Util\r\n * @param {Function[]} [funcs] The functions to invoke.\r\n * @returns {Function} Returns the new composite function.\r\n * @see flowRight\r\n * @example\r\n *\r\n * function square(n) {\r\n *   return n * n\r\n * }\r\n *\r\n * const addSquare = flow([add, square])\r\n * addSquare(1, 2)\r\n * // => 9\r\n */",
    "meta": {
        "range": [
            547,
            994
        ],
        "filename": "flow.js",
        "lineno": 21,
        "path": "C:\\Users\\beaujeup\\projects\\jsdoc-template\\examples\\lodash\\lodash-repo",
        "code": {
            "id": "astnode100002788",
            "name": "flow",
            "type": "FunctionDeclaration",
            "paramnames": [
                "funcs"
            ]
        },
        "vars": {
            "length": "flow~length",
            "index": "flow~index",
            "": null
        }
    },
    "description": "Composes a function that returns the result of invoking the given functions\rwith the `this` binding of the created function, where each successive\rinvocation is supplied the return value of the previous.",
    "since": "3.0.0",
    "tags": [
        {
            "originalTitle": "category",
            "title": "category",
            "text": "Util",
            "value": "Util"
        }
    ],
    "params": [
        {
            "type": {
                "names": [
                    "Array."
                ]
            },
            "optional": true,
            "description": "The functions to invoke.",
            "name": "funcs"
        }
    ],
    "returns": [
        {
            "type": {
                "names": [
                    "function"
                ]
            },
            "description": "Returns the new composite function."
        }
    ],
    "see": [
        "flowRight"
    ],
    "examples": [
        "function square(n) {\r  return n * n\r}\r\rconst addSquare = flow([add, square])\raddSquare(1, 2)\r// => 9"
    ],
    "name": "flow",
    "longname": "flow",
    "kind": "function",
    "scope": "global",
    "___id": "T000002R000300",
    "___s": true,
    "filepath": "flow.js"
}