Skip to content

Omit emptry arrays, objects and strings

License

Notifications You must be signed in to change notification settings

mike1pol/omit-empty

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 '@mikepol/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}

omitEmpty({a: null, b: ''});
//=> null

Tests

npm install && npm test