Apply a function to each property of an object
npm install property-map
propertyMap(baseObj, callback [, thisObject]);
callback is a function that can accept up to three arguments:
value
The value for each property in baseObj
key (optional)
The key for each property in baseObj
baseObj (optional)
The baseObj
// commonJS...
var propertyMap = require('property-map');
// ...or es2015
import propertyMap from 'property-map';
propertyMap({height: 4, width: 3}, x => x + 1); // {height: 5, width: 4}
propertyMap(
{a: 4, b: 6, c: 3},
function(_, key) {return this[key]},
{a: 1, c: 3}
); // {a: 1, b: undefined, c: 3}
npm test