cleaner-node
Advanced tools
Comparing version 0.17.5 to 0.17.6
{ | ||
"name": "cleaner-node", | ||
"version": "0.17.5", | ||
"version": "0.17.6", | ||
"description": "Helpful utilities and scripts to make Node projects more legible and easier for the next developer to take over.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -169,7 +169,7 @@ const { isValid: isValidString, toCamelCase } = require('./strings'); | ||
// ----- prune | ||
const _prune = obj => { | ||
const _prune = (obj, deNull) => { | ||
if (typeof obj !== 'object' || obj === null) { return; } | ||
if (obj instanceof Array) { | ||
for (let i = 0; i < obj.length; i += 1) { | ||
_prune(obj[i]); | ||
_prune(obj[i], deNull); | ||
} | ||
@@ -184,3 +184,3 @@ return; | ||
.forEach(key => { | ||
_prune(obj[key]); | ||
_prune(obj[key], deNull); | ||
}); | ||
@@ -208,2 +208,10 @@ | ||
// Null values | ||
if (deNull) { | ||
keys.filter(key => (obj[key] === null)) | ||
.forEach(key => { | ||
Reflect.deleteProperty(obj, key); | ||
}); | ||
} | ||
// Empty Objects | ||
@@ -215,5 +223,5 @@ keys.filter(key => (isValid(obj[key]) && !(obj[key] instanceof Date) && Object.keys(obj[key]).filter(isValidString).length === 0)) | ||
}; | ||
const prune = obj => { | ||
const prune = (obj, deNull = false) => { | ||
const result = { obj }; | ||
_prune(result); | ||
_prune(result, deNull); | ||
return result.obj; | ||
@@ -220,0 +228,0 @@ }; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
82870
2102