New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

coercion

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

coercion - npm Package Compare versions

Comparing version 0.5.0 to 0.6.0

44

lib/parsers.js

@@ -46,15 +46,34 @@ var boolean, csv, date, dateRange, dateRangeRegex, dateRegex, integer, intersection, pagination, positiveInteger, sort,

csv = function(string, opt) {
var fields, _ref;
var all, allowed, fields, wildcard, _i, _len, _ref, _ref1;
if (opt == null) {
opt = {};
}
opt["default"] || (opt["default"] = []);
if (typeof string === 'number') {
string = String(string);
string = string.toString();
}
if (typeof string !== 'string') {
return opt["default"];
return opt["default"] || [];
}
if ((_ref = opt.allowed) != null ? _ref.length : void 0) {
fields = intersection(opt.allowed, string.split(','));
all = string.split(',');
allowed = opt.allowed.reduce(function(res, field) {
var prefix;
if (prefix = field.match(/(.*\.)\*$/)) {
res.wildcards.push(prefix[1]);
} else {
res.fields.push(field);
}
return res;
}, {
fields: [],
wildcards: []
});
fields = intersection(allowed.fields, all);
_ref1 = allowed.wildcards;
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
wildcard = _ref1[_i];
fields = fields.concat(all.filter(function(val) {
return val.indexOf(wildcard) === 0;
}));
}
} else {

@@ -66,3 +85,3 @@ fields = string.split(',');

}
return opt["default"];
return opt["default"] || [];
};

@@ -81,12 +100,9 @@

}
if (opt["default"] === void 0 || opt["default"] === null) {
opt["default"] = 0;
if (!(number = Math.round(number))) {
return opt["default"] || 0;
}
if (!(number = parseInt(number))) {
return opt["default"];
}
if (opt.max !== void 0) {
if (opt.max != null) {
number = Math.min(number, opt.max);
}
if (opt.min !== void 0) {
if (opt.min != null) {
number = Math.max(number, opt.min);

@@ -129,3 +145,3 @@ }

if (typeof string === 'number') {
string = String(string);
string = string.toString();
}

@@ -132,0 +148,0 @@ if (typeof string === 'string' && (string = string != null ? string.match(new RegExp(dateRangeRegex)) : void 0)) {

{
"name": "coercion",
"version": "0.5.0",
"version": "0.6.0",
"description": "Helper module to parse/cast/coerce strings.",

@@ -5,0 +5,0 @@ "main": "./index.coffee",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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