Home

Awesome

compact-object NPM version Build Status

Similar to omit-empty, recursively omits empty properties, but also compacts/flattens nested arrays in an object.

Also see omit-empty.

Install with npm

npm i compact-object --save

Running tests

Install dev dependencies.

npm i -d && npm test

Usage

var compact = require('compact-object');

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

compact({a: 'a', b: {c: 'c', d: ''});
//=> {a: 'a', b: {c: 'c'}

compact({a: ['a'], b: [['foo'], [], ['baz']]});
//=> {a: ['a'], b: ['foo', 'baz']}

compact({a: 0, b: 1});
//=> {a: 0, b: 1}

// set the `noZero` flag
compact({a: 0, b: 1}, true);
//=> {b: 1}

Author

Jon Schlinkert

License

Copyright (c) 2015 Jon Schlinkert
Released under the MIT license


This file was generated by verb-cli on March 24, 2015.