mirror of
https://github.com/denoland/deno.git
synced 2025-01-21 21:50:00 -05: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)) {
|
||||
|
|
|
@ -11,7 +11,8 @@
|
|||
|
||||
const { cloneValue, setFunctionName } = window.__bootstrap.webUtil;
|
||||
const { assert, AssertionError } = window.__bootstrap.util;
|
||||
const { customInspect, inspect } = window.__bootstrap.console;
|
||||
|
||||
const customInspect = Symbol.for("Deno.customInspect");
|
||||
|
||||
const sym = {
|
||||
abortAlgorithm: Symbol("abortAlgorithm"),
|
||||
|
@ -636,9 +637,7 @@
|
|||
}
|
||||
|
||||
[customInspect]() {
|
||||
return `${this.constructor.name} {\n readable: ${
|
||||
inspect(this.readable)
|
||||
}\n writable: ${inspect(this.writable)}\n}`;
|
||||
return this.constructor.name;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
((window) => {
|
||||
const core = window.Deno.core;
|
||||
const { customInspect } = window.__bootstrap.console;
|
||||
const { isIterable, requiredArguments } = window.__bootstrap.webUtil;
|
||||
|
||||
/** https://url.spec.whatwg.org/#idna */
|
||||
|
@ -492,7 +491,7 @@
|
|||
class URL {
|
||||
#searchParams = null;
|
||||
|
||||
[customInspect]() {
|
||||
[Symbol.for("Deno.customInspect")]() {
|
||||
const keys = [
|
||||
"href",
|
||||
"origin",
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
((window) => {
|
||||
const { DomIterableMixin } = window.__bootstrap.domIterable;
|
||||
const { requiredArguments } = window.__bootstrap.webUtil;
|
||||
const { customInspect } = window.__bootstrap.console;
|
||||
|
||||
// From node-fetch
|
||||
// Copyright (c) 2016 David Frank. MIT License.
|
||||
|
@ -194,7 +193,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
[customInspect]() {
|
||||
[Symbol.for("Deno.customInspect")]() {
|
||||
let length = this[headersData].length;
|
||||
let output = "";
|
||||
for (const [key, value] of this[headersData]) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
((window) => {
|
||||
const { customInspect } = window.__bootstrap.console;
|
||||
const customInspect = Symbol.for("Deno.customInspect");
|
||||
|
||||
class CountQueuingStrategy {
|
||||
constructor({ highWaterMark }) {
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
((window) => {
|
||||
const { opNow } = window.__bootstrap.timers;
|
||||
const { customInspect, inspect } = window.__bootstrap.console;
|
||||
const { cloneValue } = window.__bootstrap.webUtil;
|
||||
|
||||
const customInspect = Symbol.for("Deno.customInspect");
|
||||
let performanceEntries = [];
|
||||
|
||||
function findMostRecent(
|
||||
|
@ -130,7 +130,7 @@
|
|||
[customInspect]() {
|
||||
return this.detail
|
||||
? `${this.constructor.name} {\n detail: ${
|
||||
inspect(this.detail, { depth: 3 })
|
||||
JSON.stringify(this.detail, null, 2)
|
||||
},\n name: "${this.name}",\n entryType: "${this.entryType}",\n startTime: ${this.startTime},\n duration: ${this.duration}\n}`
|
||||
: `${this.constructor.name} { detail: ${this.detail}, name: "${this.name}", entryType: "${this.entryType}", startTime: ${this.startTime}, duration: ${this.duration} }`;
|
||||
}
|
||||
|
@ -170,7 +170,7 @@
|
|||
[customInspect]() {
|
||||
return this.detail
|
||||
? `${this.constructor.name} {\n detail: ${
|
||||
inspect(this.detail, { depth: 3 })
|
||||
JSON.stringify(this.detail, null, 2)
|
||||
},\n name: "${this.name}",\n entryType: "${this.entryType}",\n startTime: ${this.startTime},\n duration: ${this.duration}\n}`
|
||||
: `${this.constructor.name} { detail: ${this.detail}, name: "${this.name}", entryType: "${this.entryType}", startTime: ${this.startTime}, duration: ${this.duration} }`;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue