Reputation: 1919
Is there a lodash function that transforms one plainObject to another plainObject by running each of the first objects values through an iterator and keeping the same keys?
Example:
var example = {a: 2}
_.mapObject(example, function(value, key) {return key++}) === {a: 3}
Basically I just need an hashtable parallel for calling _.map on an array.
Upvotes: 0
Views: 88
Reputation: 106027
Yep, it's called _.mapValues
.
var example = { a: 2 };
_.mapValues(example, function(value) {
return value + 1;
});
// => { a: 3 }
Upvotes: 4