Creates a function that invokes the method at `path` of a given object. Any additional arguments are provided to the invoked method.
const objects = [
{ 'a': { 'b': constant(2) } },
{ 'a': { 'b': constant(1) } }
]
map(objects, method('a.b'))
// => [2, 1]
map(objects, method(['a', 'b']))
// => [2, 1]
| Name | Type | Attribute | Description |
|---|---|---|---|
| path | The path of the method to invoke. | ||
| args | The arguments to invoke the method with. |
{
"comment": "/**\r\n * Creates a function that invokes the method at `path` of a given object.\r\n * Any additional arguments are provided to the invoked method.\r\n *\r\n * @since 3.7.0\r\n * @category Util\r\n * @param {Array|string} path The path of the method to invoke.\r\n * @param {Array} [args] The arguments to invoke the method with.\r\n * @returns {Function} Returns the new invoker function.\r\n * @example\r\n *\r\n * const objects = [\r\n * { 'a': { 'b': constant(2) } },\r\n * { 'a': { 'b': constant(1) } }\r\n * ]\r\n *\r\n * map(objects, method('a.b'))\r\n * // => [2, 1]\r\n *\r\n * map(objects, method(['a', 'b']))\r\n * // => [2, 1]\r\n */",
"meta": {
"range": [
646,
727
],
"filename": "method.js",
"lineno": 25,
"path": "C:\\Users\\beaujeup\\projects\\jsdoc-template\\examples\\lodash\\lodash-repo",
"code": {
"id": "astnode100006273",
"name": "method",
"type": "FunctionDeclaration",
"paramnames": [
"path",
"args"
]
},
"vars": {
"": null
}
},
"description": "Creates a function that invokes the method at `path` of a given object.\rAny additional arguments are provided to the invoked method.",
"since": "3.7.0",
"tags": [
{
"originalTitle": "category",
"title": "category",
"text": "Util",
"value": "Util"
}
],
"params": [
{
"type": {
"names": [
"Array",
"string"
]
},
"description": "The path of the method to invoke.",
"name": "path"
},
{
"type": {
"names": [
"Array"
]
},
"optional": true,
"description": "The arguments to invoke the method with.",
"name": "args"
}
],
"returns": [
{
"type": {
"names": [
"function"
]
},
"description": "Returns the new invoker function."
}
],
"examples": [
"const objects = [\r { 'a': { 'b': constant(2) } },\r { 'a': { 'b': constant(1) } }\r]\r\rmap(objects, method('a.b'))\r// => [2, 1]\r\rmap(objects, method(['a', 'b']))\r// => [2, 1]"
],
"name": "method",
"longname": "method",
"kind": "function",
"scope": "global",
"___id": "T000002R000584",
"___s": true,
"filepath": "method.js"
}