1.0.2 • Published 9 years ago
object-map v1.0.2
Map a function over the values of an Object to produce a new Object with the same keys.
The API is modelled after the native Array#map method.
Installation
$ npm install --save object-mapExample
var objectMap = require('object-map');
var target = {
foo: 1,
bar: 2
};
var result = objectMap(target, function(value) {
return value * value;
});
// => {foo: 1, bar: 4}API
objectMap(target, callback[, thisArg])
targetan object who's properties are iterated usinghasOwnPropertycallbacka function producing a value of the new Object, taking three arguments:currentValuethe value currently associated with the keykeythe current keyobjectthe original object passed toobjectMap
thisArgOptional. Value to use asthiswhen executingcallback.