michaelleeallen/augmentjs — pull request #6 by awagner83 (2013-10-16 11:37:20+00:00)
Title: New Object methods: fromPairs, toPairs, map, and flip.

This one has quite a few changes, so I don't expect it to go in without a fight.

My main motivation was to implement an `Object.map` that works like `Array.map`, but returns objects. I do this all the time with underscore, but even with underscore, it's a bit clunky:

mapped = _.object(_.map(_.pairs(someObject, someFunction)));

or, using _.chain

mapped = _.chain(someObject).pairs().map(someFunction).object().value();

whereas, with Object.map presented here, I can do this:

mapped = someObject.map(someFunction);

This was the reason why `Object.map` has to be renamed (I've picked `.translate` and `.reverseTranslation`)

Also, I wasn't sure about my `Object.fromPairs` constructor. I feel it may violate the spirit of your 'fluid' interface idea, but if I don't use this, I'd need to add a new function to Array, and find some clever name to indicate it takes a list of pairs and converts it to an object, which I don't believe is an easy task.