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

xiaoliwang picture xiaoliwang  路  3Comments

chikamichi picture chikamichi  路  8Comments

githublyp picture githublyp  路  3Comments

acl0056 picture acl0056  路  5Comments

umarfarooq125 picture umarfarooq125  路  8Comments