Creates an object with the same keys as `object` and values generated by running each own enumerable string keyed property of `object` thru `iteratee`. The iteratee is invoked with three arguments: (value, key, object).
const users = {
'fred': { 'user': 'fred', 'age': 40 },
'pebbles': { 'user': 'pebbles', 'age': 1 }
}
mapValues(users, ({ age }) => age)
// => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
| Name | Type | Attribute | Description |
|---|---|---|---|
| object | The object to iterate over. | ||
| iteratee | The function invoked per iteration. |
{
"comment": "/**\r\n * Creates an object with the same keys as `object` and values generated\r\n * by running each own enumerable string keyed property of `object` thru\r\n * `iteratee`. The iteratee is invoked with three arguments:\r\n * (value, key, object).\r\n *\r\n * @since 2.4.0\r\n * @category Object\r\n * @param {Object} object The object to iterate over.\r\n * @param {Function} iteratee The function invoked per iteration.\r\n * @returns {Object} Returns the new mapped object.\r\n * @see mapKeys\r\n * @example\r\n *\r\n * const users = {\r\n * 'fred': { 'user': 'fred', 'age': 40 },\r\n * 'pebbles': { 'user': 'pebbles', 'age': 1 }\r\n * }\r\n *\r\n * mapValues(users, ({ age }) => age)\r\n * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)\r\n */",
"meta": {
"range": [
805,
1011
],
"filename": "mapValues.js",
"lineno": 25,
"path": "C:\\Users\\beaujeup\\projects\\jsdoc-template\\examples\\lodash\\lodash-repo",
"code": {
"id": "astnode100005867",
"name": "mapValues",
"type": "FunctionDeclaration",
"paramnames": [
"object",
"iteratee"
]
},
"vars": {
"result": "mapValues~result",
"": null
}
},
"description": "Creates an object with the same keys as `object` and values generated\rby running each own enumerable string keyed property of `object` thru\r`iteratee`. The iteratee is invoked with three arguments:\r(value, key, object).",
"since": "2.4.0",
"tags": [
{
"originalTitle": "category",
"title": "category",
"text": "Object",
"value": "Object"
}
],
"params": [
{
"type": {
"names": [
"Object"
]
},
"description": "The object to iterate over.",
"name": "object"
},
{
"type": {
"names": [
"function"
]
},
"description": "The function invoked per iteration.",
"name": "iteratee"
}
],
"returns": [
{
"type": {
"names": [
"Object"
]
},
"description": "Returns the new mapped object."
}
],
"see": [
"mapKeys"
],
"examples": [
"const users = {\r 'fred': { 'user': 'fred', 'age': 40 },\r 'pebbles': { 'user': 'pebbles', 'age': 1 }\r}\r\rmapValues(users, ({ age }) => age)\r// => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)"
],
"name": "mapValues",
"longname": "mapValues",
"kind": "function",
"scope": "global",
"___id": "T000002R000546",
"___s": true,
"filepath": "mapValues.js"
}