Skip to content

Latest commit

 

History

History
25 lines (17 loc) · 548 Bytes

.verb.md

File metadata and controls

25 lines (17 loc) · 548 Bytes

Heads up!

Breaking changes in v1.0.0! See the Release History.

Usage

const omitEmpty = require('{%= name %}');

console.log(omitEmpty({ a: 'a', b: '' }));
//=> { a: 'a' }

console.log(omitEmpty({ a: 'a', b: { c: 'c', d: '' } }));
//=> { a: 'a', b: { c: 'c' } }

console.log(omitEmpty({ a: ['a'], b: [] }));
//=> { a: ['a'] }

console.log(omitEmpty({ a: 0, b: 1 }));
//=> { a: 0, b: 1 }

// set omitZero to true, to evaluate "0" as falsey
console.log(omitEmpty({ a: 0, b: 1 }, { omitZero: true }));
//=> { b: 1 }