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

arieljake picture arieljake  ·  4Comments

chikamichi picture chikamichi  ·  8Comments

markvr picture markvr  ·  3Comments

marcalj picture marcalj  ·  5Comments

acl0056 picture acl0056  ·  5Comments