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.16.0 to 0.17.0

2

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

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

| 0.16.0 | 2021/08/29 | Add improved `objects.toDto`. |
| 0.17.0 | 2021/09/15 | Add `express.getValue`. |

@@ -0,1 +1,3 @@

const objects = require('./objects');
const asyncMiddleware = (fn) => {

@@ -7,6 +9,30 @@ return (req, res, next) => {

const getProperty = (obj, key, isCaseSensitive = false) => {
if (!objects.isValid(obj)) { return undefined; }
const keys = Object.keys(obj).filter(x => (x &&
((!isCaseSensitive && x.toLowerCase() === key.toLowerCase()) ||
(isCaseSensitive && x === key))));
return (keys.length === 0)
? obj[keys[0]]
: obj[key];
};
const getValueFromBody = (req, key, isCaseSensitive = false) => {
return getProperty(req.body, key, isCaseSensitive);
};
const getValueFromParams = (req, key, isCaseSensitive = false) => {
return getProperty(req.body, key, isCaseSensitive);
};
const getValue = (req, key, isCaseSensitive = false) => {
return getValueFromBody(req, key, isCaseSensitive) || getValueFromParams(req, key, isCaseSensitive);
};
module.exports = {
asyncMiddleware,
amw : asyncMiddleware,
wrap : asyncMiddleware
wrap : asyncMiddleware,
getValue,
getValueFromBody,
getValueFromParams
};
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