@mikepol/omit-empty

1.0.0 • Public • Published

omit-empty

NPM version NPM downloads Build Status

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

Package Sidebar

Install

npm i @mikepol/omit-empty

Weekly Downloads

0

Version

1.0.0

License

MIT

Last publish

Collaborators

  • mikepol