Underscore: _.mapKeys to map object keys

Created on 3 May 2016  路  3Comments  路  Source: jashkenas/underscore

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]]
    )
  );

wontfix

Most helpful comment

All 3 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zackschuster picture zackschuster  路  5Comments

xiaoliwang picture xiaoliwang  路  3Comments

dmaicher picture dmaicher  路  9Comments

sky0014 picture sky0014  路  8Comments

Francefire picture Francefire  路  5Comments