redact-object
Advanced tools
Comparing version 2.1.0 to 2.2.0
19
index.js
@@ -11,2 +11,6 @@ 'use strict'; | ||
function isFunction (value) { | ||
return typeof value === 'function'; | ||
} | ||
/** | ||
@@ -16,5 +20,5 @@ * Checks for match | ||
* @param {string} key The string to check | ||
* @param {Boolean} strict Use strict case if true | ||
* @param {Boolean} partial Use partial matching if true | ||
* @return {Boolean} True for match or false | ||
* @param {boolean} strict Use strict case if true | ||
* @param {boolean} partial Use partial matching if true | ||
* @return {boolean} True for match or false | ||
*/ | ||
@@ -42,2 +46,3 @@ function isKeywordMatch (keywords, key, strict, partial) { | ||
* strict: boolean, do strict key matching, default true | ||
* ignoreFunctions: boolean, ignore functions instead of error, default false | ||
* } | ||
@@ -50,2 +55,3 @@ * @return {object} the new redacted object | ||
const strict = config.hasOwnProperty('strict') ? config.strict : true; | ||
const ignoreFunctions = config.hasOwnProperty('ignoreFunctions') ? config.ignoreFunctions : false; | ||
@@ -74,5 +80,10 @@ if (!isObject(target)) { | ||
// Redaction only works on arrays, plain objects, and primitives. | ||
throw new Error('Unsupported value for redaction'); | ||
if (isFunction(target) && ignoreFunctions) { | ||
// ignore the function instead of throwing an error | ||
return target; | ||
} else { | ||
throw new Error('Unsupported value for redaction'); | ||
} | ||
} | ||
module.exports = redact; |
{ | ||
"name": "redact-object", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"description": "Object redactor", | ||
@@ -25,3 +25,3 @@ "main": "index.js", | ||
], | ||
"author": "Shaun Buridck <github@shaunburdick.com>", | ||
"author": "Shaun Burdick <github@shaunburdick.com>", | ||
"contributors": [ | ||
@@ -32,7 +32,7 @@ "Parsha Pourkhomami <parshap@gmail.com>" | ||
"devDependencies": { | ||
"coveralls": "^3.0.1", | ||
"jasmine-node": "^1.14.5", | ||
"nyc": "^12.0.2", | ||
"coveralls": "^3.0.2", | ||
"jasmine-node": "^1.16.2", | ||
"nyc": "^13.0.1", | ||
"semistandard": "^12.0.1", | ||
"snazzy": "^7.1.1" | ||
"snazzy": "^8.0.0" | ||
}, | ||
@@ -39,0 +39,0 @@ "homepage": "https://github.com/shaunburdick/redact-object", |
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
7202
76