package
Recursively compacts collection values (arrays and objects), removing empty values from your arrays & objects
npm install deep-compactGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Recursively compacts collection values (arrays and objects), removing empty values from your arrays & objects.
It will also trim and remove empty strings.
$ npm install deep-compact - NPM
$ bower install deep-compact - bower
The browser file is named index.umd.js which supports CommonJS, AMD and globals (deepCompact).
If you want to run this module on old browsers, you must include es5-shim.
var deepcompact = require('deep-compact');
deepcompact({
something: [
{
colors: ['red', ' green ', ''],
cars: { audi: 'nice', vw: 'good', aston: ' ' }
},
undefined,
''
],
foo: 'bar'
});
/*
{
something: [
{
colors: ['red', 'green'],
cars: { audi: 'nice', vw: 'good' }
}
],
foo: 'bar'
});
*/Additionally, deepcompact.isEmpty is exposed because it might be useful to use directly.
$ npm test
Released under the MIT License.
Estimated unpacked size across 3 packages.
6.6 kB
Includes dependencies.
^2.0.1
5.1.0