summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/script/_bootstrap/default.js26
1 files changed, 15 insertions, 11 deletions
diff --git a/modules/script/_bootstrap/default.js b/modules/script/_bootstrap/default.js
index 91b5eca1..161418c0 100644
--- a/modules/script/_bootstrap/default.js
+++ b/modules/script/_bootstrap/default.js
@@ -24,19 +24,23 @@
}
function prettyPrint(value) {
- if (value.toString === Object.prototype.toString || value.toString === Array.prototype.toString || value.toString === Function.prototype.toString || value.toString === Date.prototype.toString) {
- const printedObjects = new WeakSet();
- switch (typeof value) {
- case 'object':
+ switch (typeof value) {
+ case 'object':
+ if (value.toString === Object.prototype.toString ||
+ value.toString === Array.prototype.toString ||
+ value.toString === Date.prototype.toString) {
+ const printedObjects = new WeakSet();
return formatObject(value, printedObjects);
- case 'function':
- return formatFunction(value);
- default:
- return value.toString();
}
- } else {
- if (typeof value === 'string')
- return JSON.stringify(value);
+ // If the object has a nonstandard toString, prefer that
+ return value.toString();
+ case 'function':
+ if (value.toString === Function.prototype.toString)
+ return formatFunction(value);
+ return value.toString();
+ case 'string':
+ return JSON.stringify(value);
+ default:
return value.toString();
}
}