1.1.0 • Published 7 years ago

deep-compact v1.1.0

Weekly downloads
1,850
License
MIT
Repository
github
Last release
7 years ago

deep-compact

NPM version Downloads Build Status Dependency status Dev Dependency status

Recursively compacts collection values (arrays and objects), removing empty values from your arrays & objects.
It will also trim and remove empty strings.

Installation

$ 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.

Usage

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.

Tests

$ npm test

License

Released under the MIT License.

1.1.0

7 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago

0.2.4

9 years ago

0.2.2

9 years ago

0.2.1

9 years ago

0.2.0

9 years ago

0.1.2

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago