Comparing version 7.3.0 to 7.4.0
@@ -18,6 +18,7 @@ /** | ||
* @param {Boolean} allowNull [defaults to false] | ||
* @param {Boolean} dontStringifyFunctions [defaults to false] | ||
* @return {String} | ||
*/ | ||
module.exports = function dehydrate (value, allowNull) { | ||
return rebuildSanitized(value,allowNull); | ||
module.exports = function dehydrate (value, allowNull, dontStringifyFunctions) { | ||
return rebuildSanitized(value,allowNull,dontStringifyFunctions); | ||
}; |
@@ -15,3 +15,3 @@ /** | ||
*/ | ||
module.exports = function rebuildSanitized(val, allowNull) { | ||
module.exports = function rebuildSanitized(val, allowNull, dontStringifyFunctions) { | ||
@@ -26,3 +26,3 @@ // Does not `allowNull` by default. | ||
return _rebuild(val, allowNull); | ||
return _rebuild(val, allowNull, dontStringifyFunctions); | ||
}; | ||
@@ -58,3 +58,3 @@ | ||
function _rebuild(val, allowNull) { | ||
function _rebuild(val, allowNull, dontStringifyFunctions) { | ||
var stack = []; | ||
@@ -107,3 +107,5 @@ var keys = []; | ||
else if (_.isFunction(val)){ | ||
val = val.toString(); | ||
if (!dontStringifyFunctions) { | ||
val = val.toString(); | ||
} | ||
} | ||
@@ -145,4 +147,5 @@ else if (!_.isObject(val)) { | ||
// Pass in the empty string to satisfy Mr. isaac's replacer | ||
// Pass in the empty string for the top-level "key" | ||
// to satisfy Mr. isaac's replacer | ||
return _recursivelyRebuildAndSanitize(val, ''); | ||
} |
{ | ||
"name": "rttc", | ||
"version": "7.3.0", | ||
"version": "7.4.0", | ||
"description": "Runtime type-checking for JavaScript.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -130,3 +130,3 @@ # rttc | ||
The **lamda** type accepts any function. | ||
The **lamda** type accepts any function. | ||
@@ -331,7 +331,7 @@ ### Generic dictionaries | ||
##### .dehydrate(value, [_allowNull_=`false`]) | ||
##### .dehydrate(value, [_allowNull_=`false`], [_dontStringifyFunctions_=`false`]) | ||
This takes care of a few serialization edge-cases, such as: | ||
+ stringifies functions, regexps, and errors (grabs the `.stack` property) | ||
+ stringifies regexps, errors (grabs the `.stack` property), and functions (unless `dontStringifyFunctions` is set) | ||
+ replacing circular references with a string (e.g. `[Circular]`) | ||
@@ -338,0 +338,0 @@ + replaces `-Infinity`, `Infinity`, and `NaN` with 0 |
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
199085
4215