diff options
Diffstat (limited to 'src/utility.js')
-rw-r--r-- | src/utility.js | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/utility.js b/src/utility.js index 737d515a..e49776d8 100644 --- a/src/utility.js +++ b/src/utility.js @@ -284,3 +284,13 @@ function jsonCompare(x, y) { return JSON.stringify(x) == JSON.stringify(y); } +function stringifyWithFunctions(obj) { + if (typeof obj === 'function') return obj.toString(); + if (obj === null || typeof obj !== 'object') return JSON.stringify(obj); + if (isArray(obj)) { + return '[' + obj.map(stringifyWithFunctions).join(',') + ']'; + } else { + return '{' + keys(obj).map(function(key) { return key + ':' + stringifyWithFunctions(obj[key]) }).join(',') + '}'; + } +} + |