object-transmute
object-transmute allows you to run objects through a series of transmutations.
Installation
npm install --save object-transmute
Usage
The module exports a single function: transmute
var transmute = ; var object = foo: null obj: yak: true emu: false deeper: sloth: true array: one: true two: true three: true otherArray: one: true two: true three: true ; var transmuted = ; console;
Will result in an object that has been run through the following transmutations in order:
- filter - only allow through the specified fields
- remove - remove only the specified fields
- process - process the specified fields using the given processors
{ "obj": { "YAK": true, "DEEPER": { "sloth": true } }, "array": [ { "one": true }, { "two": true }, { "three": true } ], "otherArray": [ { "one": true }, { "two": true } ]}
Contributing
Pull requests are very welcome! Just make sure your code:
-
Passes jshint given the included .jshintrc
-
Is beautified using jsbeautifier and the included .jsbeautifyrc
Why?
I wanted a simple, reusable way to filter objects.
CHANGELOG
v0.1.0
- Initial release.