Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

clean-deep

Package Overview
Dependencies
Maintainers
3
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clean-deep - npm Package Compare versions

Comparing version 3.1.0 to 3.2.0

4

CHANGELOG.md
# Changelog
## [v3.2.0](https://github.com/nunofgs/clean-deep/releases/tag/v3.2.0) (2019-12-04)
- add cleanKeys option [\#35](https://github.com/nunofgs/clean-deep/pull/35) ([kalimantos](https://github.com/kalimantos))
- Fixed wrong wording [\#32](https://github.com/nunofgs/clean-deep/pull/32) ([lindekaer](https://github.com/lindekaer))
## [v3.1.0](https://github.com/nunofgs/clean-deep/releases/tag/v3.1.0) (2019-10-15)

@@ -4,0 +8,0 @@ - Add custom values support [\#31](https://github.com/nunofgs/clean-deep/pull/31) ([nunofgs](https://github.com/nunofgs))

2

package.json
{
"name": "clean-deep",
"version": "3.1.0",
"version": "3.2.0",
"description": "Remove falsy, empty or nullable values from objects",

@@ -5,0 +5,0 @@ "keywords": [

@@ -28,2 +28,3 @@ # clean-deep

----------------- | ------------- | -----------------------------------
_cleanKeys_ | _[]_ | Remove specific keys, ie: `['foo', 'bar', ' ']`
_cleanValues_ | _[]_ | Remove specific values, ie: `['foo', 'bar', ' ']`

@@ -34,3 +35,3 @@ _emptyArrays_ | _true_ | Remove empty arrays, ie: `[]`

_nullValues_ | _true_ | Remove null values, ie: `null`
_undefinedValues_ | _true_ | Remove null values, ie: `undefined`
_undefinedValues_ | _true_ | Remove undefined values, ie: `undefined`

@@ -37,0 +38,0 @@ _(Object)_: Returns the cleansed object.

@@ -15,2 +15,3 @@

module.exports = function cleanDeep(object, {
cleanKeys = [],
cleanValues = [],

@@ -24,5 +25,10 @@ emptyArrays = true,

return transform(object, (result, value, key) => {
// Exclude specific keys.
if (cleanKeys.includes(key)) {
return;
}
// Recurse into arrays and objects.
if (Array.isArray(value) || isPlainObject(value)) {
value = cleanDeep(value, { cleanValues, emptyArrays, emptyObjects, emptyStrings, nullValues, undefinedValues });
value = cleanDeep(value, { cleanKeys, cleanValues, emptyArrays, emptyObjects, emptyStrings, nullValues, undefinedValues });
}

@@ -29,0 +35,0 @@

@@ -178,2 +178,28 @@

});
it('should remove specified keys if `cleanKeys` is passed', () => {
const object = {
foo: {
alsoMe: {
biz: 123,
},
bar: undefined,
biz: 123,
qux: [
undefined,
{},
true
],
removeMe: true,
},
removeMe: true,
};
expect(cleanDeep(object, { cleanKeys: ['removeMe', 'alsoMe'] })).toEqual({
foo: {
biz: 123,
qux: [true]
}
});
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc