Closed masciugo closed 4 years ago
Hi, currently there is no such method, I'll think about adding it in future release, when I'll have a bit of free time. If you need it right now you can use reduceDeep instead
For the sake of completeness, a specific method would be the best solution. But this is my implementation, which is quite satisfying
mapDeep( obj, (value, key, parentValue, context) => {
if (_.isPlainObject(value)) {
return _.mapKeys(value, (v,k) => {
switch (k) {
case 'id':
return 'value'
case 'name':
return 'label'
default:
return k
}
})
} else {
return value
}
})
Looks like I've chosen the wrong name for mapDeep
.
It actually should be mapValuesDeep, same as in lodash for one preserving object structure to be pair for mapKeysDeep
requested above.
And mapDeep
is the correct name for 'collectDeep' planned in #42
done in v5,0,0 (that was tricky :sweat_smile:) mapKeysDeep also "old" mapDeep was renamed to mapValuesDeep and implemented again to return just array
How can I deeply transform keys with deepdash?