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

cleaner-node

Package Overview
Dependencies
Maintainers
1
Versions
176
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.0 to 0.8.1

2

package.json
{
"name": "cleaner-node",
"version": "0.8.0",
"version": "0.8.1",
"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",

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

| 0.8.0 | 2020/01/16 | Add `env` methods. |
| 0.8.1 | 2020/01/17 | Add `.print` and `.toPrintable` to `object`. |

@@ -213,2 +213,52 @@ const { isValid: isValidString, toCamelCase } = require('./strings');

const _toPrintable = (value, valuePath, results) => {
if (typeof value === 'undefined') {
results.items.push({
key: valuePath,
value: undefined
});
} else if (value === null) {
results.items.push({
key: valuePath,
value: null
});
} else if (['string', 'number', 'boolean'].includes(typeof value)) {
results.items.push({
key: valuePath,
value
});
} else if (typeof value === 'object' && value instanceof Array) {
for (let i = 0; i < value.length; i += 1) {
if (results.cache.includes(value[i])) { return; }
results.cache.push(value[i]);
_toPrintable(value[i], `${valuePath}[${i}]`, results);
}
} else if (isValid(value)) {
if (results.cache.includes(value)) { return; }
results.cache.push(value);
const keys = Object.keys(value).filter(isValidString);
keys.sort();
keys.forEach(key => {
const keyPath = [].concat(valuePath.split('.'), key).filter(isValidString).join('.');
_toPrintable(value[key], keyPath, results);
});
}
};
const toPrintable = (value) => {
if (!isValid(value)) { throw new Error('Value passed to toPrintable is not an object.'); }
const results = {
items: [],
cache: []
};
_toPrintable(value, '', results);
return results.items;
};
const print = value => {
if (!isValid(value)) { throw new Error('Value passed to print is not an object.'); }
toPrintable(value).filter(isValid).forEach(item => {
console.log(`${item.key} : ${item.value}`);
});
};
module.exports = {

@@ -233,3 +283,5 @@ findOne,

toDtos,
toPrintable,
print,
reduce
};
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