rttc
Advanced tools
Comparing version 10.0.0-3 to 10.0.0-4
@@ -19,6 +19,9 @@ /** | ||
* @param {Boolean} allowNaNAndFriends [defaults to false] | ||
* @param {Boolean} doRunToJSONMethods [defaults to false] | ||
* ^^^^^^^^^^^^^^^^^^ | ||
* (only applies to certain things -- see https://trello.com/c/5SkpUlhI/402-make-customtojson-work-with-actions2#comment-5a3b6e7b43107b7a2938e7bd) | ||
* @return {String} | ||
*/ | ||
module.exports = function dehydrate (value, allowNull, dontStringifyFunctions, allowNaNAndFriends) { | ||
return rebuildSanitized(value, allowNull, dontStringifyFunctions, allowNaNAndFriends); | ||
module.exports = function dehydrate (value, allowNull, dontStringifyFunctions, allowNaNAndFriends, doRunToJSONMethods) { | ||
return rebuildSanitized(value, allowNull, dontStringifyFunctions, allowNaNAndFriends, doRunToJSONMethods); | ||
}; |
@@ -21,4 +21,7 @@ /** | ||
* @param {Boolean?} allowNaNAndFriends | ||
* @param {Boolean?} doRunToJSONMethods | ||
* ^^^^^^^^^^^^^^^^^^ | ||
* (only applies to certain things -- see https://trello.com/c/5SkpUlhI/402-make-customtojson-work-with-actions2#comment-5a3b6e7b43107b7a2938e7bd) | ||
*/ | ||
module.exports = function rebuildSanitized(val, allowNull, dontStringifyFunctions, allowNaNAndFriends) { | ||
module.exports = function rebuildSanitized(val, allowNull, dontStringifyFunctions, allowNaNAndFriends, doRunToJSONMethods) { | ||
@@ -33,3 +36,3 @@ // Does not `allowNull` by default. | ||
return _rebuild(val, allowNull, dontStringifyFunctions, allowNaNAndFriends); | ||
return _rebuild(val, allowNull, dontStringifyFunctions, allowNaNAndFriends, doRunToJSONMethods); | ||
}; | ||
@@ -65,3 +68,3 @@ | ||
function _rebuild(val, allowNull, dontStringifyFunctions, allowNaNAndFriends) { | ||
function _rebuild(val, allowNull, dontStringifyFunctions, allowNaNAndFriends, doRunToJSONMethods) { | ||
var stack = []; | ||
@@ -105,3 +108,7 @@ var keys = []; | ||
else if (_.isError(val)){ | ||
val = val.stack; | ||
if (doRunToJSONMethods && _.isFunction(val.toJSON)) { | ||
val = val.toJSON(); | ||
} else { | ||
val = val.stack; | ||
} | ||
} | ||
@@ -154,2 +161,7 @@ else if (_.isRegExp(val)){ | ||
} | ||
// Run its .toJSON() method and use the result, if appropriate. | ||
if (doRunToJSONMethods && _.isFunction(val.toJSON)) { | ||
return val.toJSON(); | ||
}//• | ||
return _.reduce(_.keys(val),function (memo, key) { | ||
@@ -156,0 +168,0 @@ var subVal = val[key]; |
{ | ||
"name": "rttc", | ||
"version": "10.0.0-3", | ||
"version": "10.0.0-4", | ||
"description": "Runtime type-checking for JavaScript.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
442537
80
8595