object-prune
v0.0.4
Published
object-prune ============ Prune objects from non-values
Downloads
30
Readme
object-prune
Prune objects from non-values
Install
npm install --save object-prune
Usage
const prune = require('object-prune')
prune(obj)
Walk an object recursively and remove
- keys with empty string values
- keys with object values without keys
- keys with array values without elements
prune({one: "", two: [], three: {}, four: 4}) // # {four: 4}
prune.emptyStrings(obj)
prune({one: "", two: [], three: {}, four: 4}) // # {two: [], three: {}, four: 4}
prune.emptyArrays(obj)
prune({one: "", two: [], three: {}, four: 4}) // # {one: "", three: {}, four: 4}
prune.emptyObjects(obj)
prune({one: "", two: [], three: {}, four: 4}) // # {one: "", two: [], four: 4}