|
1 year ago | |
---|---|---|
.. | ||
LICENSE | 1 year ago | |
README.md | 1 year ago | |
index.js | 1 year ago | |
package.json | 1 year ago | |
test.js | 1 year ago |
Mutate keys and values in objects. Returns a new version of the object
npm install toxic --save
var toxic = require('toxic');
var mutatedObject = toxic({
key1: 'value1',
key2: 'value2'
}, {
mutator: function (val) {
return val + '...'
}
});
console.log(mutatedObject);
// OUTPUTS:
// {
// 'key1...': 'value1...',
// 'key2...': 'value2...'
// }
object
- The object to perform mutations on.options
mutator
- Function that gets passed the current key or value. Default returns the value, as is.keyMutator
- Function used ot mutate the keys. Overrides mutator
.valueMutator
- Function used ot mutate the values. Overrides mutator
.npm install
npm test