This method is like `invert` except that the inverted object is generated from the results of running each element of `object` thru `iteratee`. The corresponding inverted value of each inverted key is an array of keys responsible for generating the inverted value. The iteratee is invoked with one argument: (value).
const object = { 'a': 1, 'b': 2, 'c': 1 }
invertBy(object, value => `group${ value }`)
// => { 'group1': ['a', 'c'], 'group2': ['b'] }
| Name | Type | Attribute | Description |
|---|---|---|---|
| object | The object to invert. | ||
| iteratee | The iteratee invoked per element. |
{
"comment": "/**\r\n * This method is like `invert` except that the inverted object is generated\r\n * from the results of running each element of `object` thru `iteratee`. The\r\n * corresponding inverted value of each inverted key is an array of keys\r\n * responsible for generating the inverted value. The iteratee is invoked\r\n * with one argument: (value).\r\n *\r\n * @since 4.1.0\r\n * @category Object\r\n * @param {Object} object The object to invert.\r\n * @param {Function} iteratee The iteratee invoked per element.\r\n * @returns {Object} Returns the new inverted object.\r\n * @example\r\n *\r\n * const object = { 'a': 1, 'b': 2, 'c': 1 }\r\n *\r\n * invertBy(object, value => `group${ value }`)\r\n * // => { 'group1': ['a', 'c'], 'group2': ['b'] }\r\n */",
"meta": {
"range": [
834,
1124
],
"filename": "invertBy.js",
"lineno": 23,
"path": "C:\\Users\\beaujeup\\projects\\jsdoc-template\\examples\\lodash\\lodash-repo",
"code": {
"id": "astnode100003965",
"name": "invertBy",
"type": "FunctionDeclaration",
"paramnames": [
"object",
"iteratee"
]
},
"vars": {
"result": "invertBy~result",
"": null
}
},
"description": "This method is like `invert` except that the inverted object is generated\rfrom the results of running each element of `object` thru `iteratee`. The\rcorresponding inverted value of each inverted key is an array of keys\rresponsible for generating the inverted value. The iteratee is invoked\rwith one argument: (value).",
"since": "4.1.0",
"tags": [
{
"originalTitle": "category",
"title": "category",
"text": "Object",
"value": "Object"
}
],
"params": [
{
"type": {
"names": [
"Object"
]
},
"description": "The object to invert.",
"name": "object"
},
{
"type": {
"names": [
"function"
]
},
"description": "The iteratee invoked per element.",
"name": "iteratee"
}
],
"returns": [
{
"type": {
"names": [
"Object"
]
},
"description": "Returns the new inverted object."
}
],
"examples": [
"const object = { 'a': 1, 'b': 2, 'c': 1 }\r\rinvertBy(object, value => `group${ value }`)\r// => { 'group1': ['a', 'c'], 'group2': ['b'] }"
],
"name": "invertBy",
"longname": "invertBy",
"kind": "function",
"scope": "global",
"___id": "T000002R000403",
"___s": true,
"filepath": "invertBy.js"
}