Comparing version 1.0.5 to 1.0.6
20
index.js
const sanitizer = require("./sanitizer"); | ||
module.exports = (value) => { | ||
const handlers = { | ||
const handle = { | ||
string: (str) => (str ? sanitizer(str).trim() : ""), | ||
array: (arr) => { | ||
var clone = [].concat(arr); | ||
clone.forEach((item, index) => (clone[index] = module.exports(item))); | ||
for (var i = clone.length - 1; i >= 0; i--) { | ||
clone[i] = module.exports(clone[i]); | ||
} | ||
return clone; | ||
@@ -13,5 +15,7 @@ }, | ||
var clone = JSON.parse(JSON.stringify(obj)); | ||
Object.keys(clone).forEach( | ||
(key) => (clone[key] = module.exports(clone[key])) | ||
); | ||
const cloneKeys = Object.keys(clone); | ||
for (var i = cloneKeys.length - 1; i >= 0; i--) { | ||
const cloneKey = cloneKeys[i]; | ||
clone[cloneKey] = module.exports(clone[cloneKey]); | ||
} | ||
return clone; | ||
@@ -22,9 +26,9 @@ }, | ||
? value.constructor === String | ||
? handlers.string(value) | ||
? handle.string(value) | ||
: value.constructor === Array | ||
? handlers.array(value) | ||
? handle.array(value) | ||
: value.constructor === Object | ||
? handlers.object(value) | ||
? handle.object(value) | ||
: value | ||
: value; | ||
}; |
{ | ||
"name": "sanitized", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "Recursive function that'll sanitize a string or ALL values in an object or array.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2871
44