Socket
Socket
Sign inDemoInstall

@phc/format

Package Overview
Dependencies
1
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.0 to 0.3.0

28

index.js

@@ -34,2 +34,5 @@ /* eslint-disable max-params,capitalized-comments,complexity */

}
function isNumeric(n) {
return !isNaN(parseFloat(n)) && isFinite(n);
}

@@ -74,10 +77,18 @@ /**

}
if (!objectKeys(opts.params).every(p => nameRegex.test(p))) {
const pk = objectKeys(opts.params);
if (!pk.every(p => nameRegex.test(p))) {
throw new TypeError(`params names must satisfy ${nameRegex}`);
}
const vs = objectValues(opts.params);
if (!vs.every(v => typeof v === 'string')) {
// Convert Numbers into Numeric Strings
pk.forEach(k => {
opts.params[k] =
typeof opts.params[k] === 'number'
? opts.params[k].toString()
: opts.params[k];
});
const pv = objectValues(opts.params);
if (!pv.every(v => typeof v === 'string')) {
throw new TypeError('params values must be strings');
}
if (!vs.every(v => valueRegex.test(v))) {
if (!pv.every(v => valueRegex.test(v))) {
throw new TypeError(`params values must satisfy ${valueRegex}`);

@@ -181,6 +192,11 @@ }

}
const vs = objectValues(params);
if (!vs.every(v => valueRegex.test(v))) {
const pv = objectValues(params);
if (!pv.every(v => valueRegex.test(v))) {
throw new TypeError(`params values must satisfy ${valueRegex}`);
}
const pk = objectKeys(params);
// Convert Numeric Strings into Numbers
pk.forEach(k => {
params[k] = isNumeric(params[k]) ? parseFloat(params[k]) : params[k];
});
}

@@ -187,0 +203,0 @@ }

{
"name": "@phc/format",
"version": "0.2.0",
"version": "0.3.0",
"description": "PHC string format serializer/deserializer",

@@ -5,0 +5,0 @@ "license": "MIT",

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc