Map object keys and returning a new object with key mapped.
let _ = require('underscore');
module.exports = (o, f) =>
_.object(
_.map(
_.pairs(o), (keyValue) => [f(keyValue[0], keyValue[1]), keyValue[1]]
)
);
Try _.keys
with a _.map
.
I want to have a function that returns an object with mapped keys.
mapKeys :: ( Object, KeyMappingFunction ) -> Object
This is more than combining _.keys
and _.map
.
See lodash/mapKeys or lodash.mapkeys.
Most helpful comment
See lodash/mapKeys or lodash.mapkeys.