@mikepol/omit-empty
v1.0.0
Published
Omit empty arrays, objects and strings
Downloads
1
Maintainers
Readme
omit-empty
Recursively omit empty properties from an object. Omits empty objects, arrays, strings or zero.
Install
npm i -s @mikepol/omit-empty
Usage
import omitEmpty from '@mike1pol/omit-empty';
omitEmpty({a: 'a', b: ''});
//=> {a: 'a'}
omitEmpty({a: 'a', b: {c: 'c', d: ''}});
//=> {a: 'a', b: {c: 'c'}
omitEmpty({a: ['a'], b: []});
//=> {a: ['a']}
omitEmpty({a: 0, b: 1});
//=> {a: 0, b: 1}
// set the `noZero` flag
omitEmpty({a: 0, b: 1}, true);
//=> {b: 1}
Tests
npm install && npm test