obj-transform
Generates transform functions to apply to each property of an object
Usage
// commonJS...var transform = ;// ...or es2015; // an incrementing transformerconst increment = ;// enlarge a rectangle; // {height: 5, width: 4}// move south-east; // {x: 1, y: 1}// looping transformwhile ; // ad-hoc transforma: 1 b: 2 c: 3; // {a: 1, b: 4, c: 9} // a mixin transformervar mixin = ;; // { a: 1, b: 9, c: 3 }
Install
npm install obj-transform
API
Creating a transform function
;
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
Using a transform function
;
Tests
npm test