package
Remove falsy, empty or nullable values from objects
npm install clean-deepGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Removes empty objects, arrays, empty strings, NaN, null and undefined values from objects. Does not alter the original object.
As of version 3.0.0, clean-deep traverses arrays as well as objects.
Install the package via npm:
$ npm install clean-deep --saveobject (Object): The source object.[options] (Object): An optional object with the following options:| Option | Default value | Description |
|---|---|---|
| cleanKeys | [] | Remove specific keys, ie: ['foo', 'bar', ' '] |
| cleanValues | [] | Remove specific values, ie: ['foo', 'bar', ' '] |
| emptyArrays | true | Remove empty arrays, ie: [] |
| emptyObjects | true | Remove empty objects, ie: {} |
| emptyStrings | true | Remove empty strings, ie: '' |
| NaNValues | false | Remove NaN values, ie: NaN |
(Object): Returns the cleansed object.
const cleanDeep = require('clean-deep');
const object = {
bar: {},
baz: null,
biz: 'baz',
foo: '',
net: [],
nit: undefined,
qux: {
baz: 'boz',
txi: ''
}
};
cleanDeep(object);
// => { biz: 'baz', qux: { baz: 'boz' } }$ npm testnpm version [<newversion> | major | minor | patch] -m "Release %s"MIT
ruimarinho
ruipmarinho@gmail.com
| true |
Remove null values, ie: null |
| undefinedValues | true | Remove undefined values, ie: undefined |
Estimated unpacked size across 4 packages.
15.6 kB
Includes dependencies.
3 direct dependencies.