1.0.0 • Published 7 years ago
@mikepol/omit-empty v1.0.0
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
1.0.0
7 years ago