summaryrefslogtreecommitdiff
path: root/cli/rt/02_console.js
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2020-09-17 18:42:36 +0200
committerGitHub <noreply@github.com>2020-09-17 18:42:36 +0200
commitc307e3e4be4e02de86103cd48d28f5ba3b18628d (patch)
treea6c830606fabcd1a08d81ed66ac882a5691f52a2 /cli/rt/02_console.js
parentbda937938550a0969588a6878d2fb6d72c17b22d (diff)
refactor: use Symbol.for instead of Symbol in cli/rt/ (#7537)
Diffstat (limited to 'cli/rt/02_console.js')
-rw-r--r--cli/rt/02_console.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/cli/rt/02_console.js b/cli/rt/02_console.js
index b07ccf187..b6f5bc74b 100644
--- a/cli/rt/02_console.js
+++ b/cli/rt/02_console.js
@@ -764,6 +764,19 @@
return String(value[customInspect]());
} catch {}
}
+ // This non-unique symbol is used to support op_crates, ie.
+ // in op_crates/web we don't want to depend on unique "Deno.customInspect"
+ // symbol defined in the public API. Internal only, shouldn't be used
+ // by users.
+ const nonUniqueCustomInspect = Symbol.for("Deno.customInspect");
+ if (
+ nonUniqueCustomInspect in value &&
+ typeof value[nonUniqueCustomInspect] === "function"
+ ) {
+ try {
+ return String(value[nonUniqueCustomInspect]());
+ } catch {}
+ }
if (value instanceof Error) {
return String(value.stack);
} else if (Array.isArray(value)) {