Remove empty objects, empty arrays, empty strings,
null
andundefined
values from objects.
Install
$ npm install --save obj-clean
Usage
const clean = ; ;//=> {} ;//=> {foo: 'bar'} ;//=> {foo: {bar: 'baz', bax: false}}
API
clean(obj, [options])
Returns a clean object.
obj
Type: Object
The object to clean up.
options
preserveArrays
Type: boolean
Default: true
Set to false
if you want to remove empty arrays.
cleanArrays
Type: boolean
Default: true
Set to false
if you don't want to iterate over arrays and clean all the objects inside the array.
License
MIT © Sam Verschueren