Socket
Socket
Sign inDemoInstall

cleaner-node

Package Overview
Dependencies
Maintainers
1
Versions
175
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cleaner-node - npm Package Compare versions

Comparing version 0.8.17 to 0.8.18

10

package.json
{
"name": "cleaner-node",
"version": "0.8.17",
"version": "0.8.18",
"description": "Helpful utilities and scripts to make Node projects more legible and easier for the next developer to take over.",

@@ -35,3 +35,3 @@ "main": "index.js",

"dependencies": {
"camelcase": "^5.3.1",
"camelcase": "^6.0.0",
"email-addresses": "^3.1.0",

@@ -43,5 +43,5 @@ "gravatar": "^1.8.0",

"know-your-http-well": "^0.5.0",
"md5-file": "^4.0.0",
"md5-file": "^5.0.0",
"moment": "^2.24.0",
"semver": "^7.1.3",
"semver": "^7.3.2",
"uuid": "^7.0.3",

@@ -55,7 +55,9 @@ "uuid-validate": "0.0.3"

"eslint-plugin-import": "^2.20.2",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-react": "^7.19.0",
"eslint-plugin-react-hooks": "^2.5.1",
"eslint-plugin-standard": "^4.0.1"
}
}

1

README.md

@@ -38,1 +38,2 @@ # cleaner-node

| 0.8.17 | 2020/04/02 | Extend `errors.init` to separate error details from the message. |
| 0.8.18 | 2020/04/18 | Rename `objects.reduce` to `objects.prune`. |

@@ -166,26 +166,24 @@ const { isValid: isValidString, toCamelCase } = require('./strings');

// ----- reduce
const reduce = obj => {
if (typeof obj !== 'object') { return; }
if (obj instanceof Array) { return; }
if (obj instanceof Date) { return; }
// ----- prune
const _prune = obj => {
if (typeof obj !== 'object' || obj === null) { return; }
if (obj instanceof Array) {
for (let i = 0; i < obj.length; i += 1) {
_prune(obj[i]);
}
return;
}
if (!isValid(obj)) { return; }
const keys = Object.keys(obj).filter(isValidString);
// Child Objects
keys.filter(key => (typeof obj[key] === 'object' && !(obj[key] instanceof Array) && !(obj[key] instanceof Date)))
Object.keys(obj).filter(isValidString)
.filter(key => (typeof obj[key] === 'object'))
.forEach(key => {
reduce(obj[key]);
});
_prune(obj[key]);
});
// Child Arrays
keys.filter(key => (typeof obj[key] === 'object' && (obj[key] instanceof Array)))
.forEach(key => {
obj[key].forEach(o => {
reduce(o);
});
});
const keys = Object.keys(obj).filter(isValidString);
// Empty Strings
keys.filter(key => (typeof obj[key] === 'string' && obj[key].trim().length === 0))
keys.filter(key => (typeof (obj[key]) === 'string' && obj[key].trim().length === 0))
.forEach(key => {

@@ -195,4 +193,4 @@ Reflect.deleteProperty(obj, key);

// Undefined
keys.filter(key => (typeof obj[key] === 'undefined'))
// Empty arrays
keys.filter(key => (typeof obj[key] === 'object' && (obj[key] instanceof Array) && obj[key].length === 0))
.forEach(key => {

@@ -202,10 +200,10 @@ Reflect.deleteProperty(obj, key);

// Empty Arrays
keys.filter(key => (typeof obj[key] === 'object' && (obj[key] instanceof Array) && obj[key].length === 0))
// Undefined
keys.filter(key => (typeof obj[key] === 'undefined'))
.forEach(key => {
Reflect.deleteProperty(obj, key);
});
});
// Empty Objects
keys.filter(key => (typeof obj[key] === 'object' && !(obj[key] instanceof Array) && !(obj[key] instanceof Date) && Object.keys(obj[key]).filter(isValidString).length === 0))
keys.filter(key => (isValid(obj[key]) && !(obj[key] instanceof Date) && Object.keys(obj[key]).filter(isValidString).length === 0))
.forEach(key => {

@@ -215,2 +213,6 @@ Reflect.deleteProperty(obj, key);

};
const prune = obj => {
const result = _prune({ obj });
return result.obj;
};

@@ -323,5 +325,5 @@ const _toPrintable = (value, valuePath, results) => {

print,
reduce,
prune,
remove
};
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