Skip to content

Latest commit

 

History

History
32 lines (21 loc) · 896 Bytes

README.md

File metadata and controls

32 lines (21 loc) · 896 Bytes

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