mirror of
https://github.com/denoland/deno.git
synced 2025-09-28 21:24:48 +00:00
refactor: use Symbol.for instead of Symbol in cli/rt/ (#7537)
This commit is contained in:
parent
bda9379385
commit
c307e3e4be
6 changed files with 22 additions and 12 deletions
|
@ -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)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue