Home

function: invokeMap


invokeMap(collection: Array, Object, path: Array, function, string, args: Array): Array

Invokes the method at `path` of each element in `collection`, returning an array of the results of each invoked method. Any additional arguments are provided to each invoked method. If `path` is a function, it's invoked for, and `this` bound to, each element in `collection`.

Example(s):

invokeMap([[5, 1, 7], [3, 2, 1]], 'sort')
// => [[1, 5, 7], [1, 2, 3]]

invokeMap([123, 456], String.prototype.split, [''])
// => [['1', '2', '3'], ['4', '5', '6']]

Params:

Name Type Attribute Description
collection The collection to iterate over.
path The path of the method to invoke or the function invoked per iteration.
args The arguments to invoke each method with.

Returns:

Array

  {
    "comment": "/**\r\n * Invokes the method at `path` of each element in `collection`, returning\r\n * an array of the results of each invoked method. Any additional arguments\r\n * are provided to each invoked method. If `path` is a function, it's invoked\r\n * for, and `this` bound to, each element in `collection`.\r\n *\r\n * @since 4.0.0\r\n * @category Collection\r\n * @param {Array|Object} collection The collection to iterate over.\r\n * @param {Array|Function|string} path The path of the method to invoke or\r\n *  the function invoked per iteration.\r\n * @param {Array} [args] The arguments to invoke each method with.\r\n * @returns {Array} Returns the array of results.\r\n * @example\r\n *\r\n * invokeMap([[5, 1, 7], [3, 2, 1]], 'sort')\r\n * // => [[1, 5, 7], [1, 2, 3]]\r\n *\r\n * invokeMap([123, 456], String.prototype.split, [''])\r\n * // => [['1', '2', '3'], ['4', '5', '6']]\r\n */",
    "meta": {
        "range": [
            982,
            1315
        ],
        "filename": "invokeMap.js",
        "lineno": 26,
        "path": "C:\\Users\\beaujeup\\projects\\jsdoc-template\\examples\\lodash\\lodash-repo",
        "code": {
            "id": "astnode100004100",
            "name": "invokeMap",
            "type": "FunctionDeclaration",
            "paramnames": [
                "collection",
                "path",
                "args"
            ]
        },
        "vars": {
            "index": "invokeMap~index",
            "isFunc": "invokeMap~isFunc",
            "result": "invokeMap~result",
            "": null
        }
    },
    "description": "Invokes the method at `path` of each element in `collection`, returning\ran array of the results of each invoked method. Any additional arguments\rare provided to each invoked method. If `path` is a function, it's invoked\rfor, and `this` bound to, each element in `collection`.",
    "since": "4.0.0",
    "tags": [
        {
            "originalTitle": "category",
            "title": "category",
            "text": "Collection",
            "value": "Collection"
        }
    ],
    "params": [
        {
            "type": {
                "names": [
                    "Array",
                    "Object"
                ]
            },
            "description": "The collection to iterate over.",
            "name": "collection"
        },
        {
            "type": {
                "names": [
                    "Array",
                    "function",
                    "string"
                ]
            },
            "description": "The path of the method to invoke or\r the function invoked per iteration.",
            "name": "path"
        },
        {
            "type": {
                "names": [
                    "Array"
                ]
            },
            "optional": true,
            "description": "The arguments to invoke each method with.",
            "name": "args"
        }
    ],
    "returns": [
        {
            "type": {
                "names": [
                    "Array"
                ]
            },
            "description": "Returns the array of results."
        }
    ],
    "examples": [
        "invokeMap([[5, 1, 7], [3, 2, 1]], 'sort')\r// => [[1, 5, 7], [1, 2, 3]]\r\rinvokeMap([123, 456], String.prototype.split, [''])\r// => [['1', '2', '3'], ['4', '5', '6']]"
    ],
    "name": "invokeMap",
    "longname": "invokeMap",
    "kind": "function",
    "scope": "global",
    "___id": "T000002R000413",
    "___s": true,
    "filepath": "invokeMap.js"
}