documentcloud/underscore — pull request #1068 by rpocklin (2013-04-11 21:22:15+00:00)
Title: Adding useful function _.transform to modify values of an object / hash / associative array.

Reason: There are many methods in underscore that transform array data structures, I find quite often I want to transform values of a object, either to prefix or suffix values, convert values or some other kind of uniform transformation on all the values without needing to return a new object and explicitly specify each key.

An example is converting all values of a hash from a string to a currency format, you would do:

```javascript
var hash = {cost: '55', shipping: '20', total: '75'};
var currency_hash = _.transform(hash, function(value) { return value.toCurrency() });
```

currently you would do the following:
```javascript
var hash = {cost: '55', shipping: '20', total: '75'};
var currrency_hash = {cost: '55'.toCurrency(), shipping: '20'.toCurrency(), total: '75'.toCurrency()};
```
I originally thought _.map would do this for me.

I originally wrote this also allowing it to transform the keys as well as the values but it was a bit more verbose and it's more common to want to transform the values than the keys.