compactobject
v0.0.3
Published
Returns an object with "non-empty" values only.
Downloads
6
Readme
compact-object
Returns an object with non-empty values only.
Install
npm install compactobject
bower install compact-object
Usage
var compact = require('compactobject');
var object = {
a: 'b',
foo: null,
b: false,
taco: 1,
qux: 0,
c: '',
d: [],
yo: {
wut: {
a: null,
c: 54
},
lolz: undefined
}
};
console.log(compact(object));
//
{
a: 'b',
b: false,
taco: 1,
qux: 0,
yo: {
wut: {
c: 54
}
}
}
console.log(compact('non object')); // {}
License
MIT