summaryrefslogtreecommitdiff
path: root/cli/rt
diff options
context:
space:
mode:
Diffstat (limited to 'cli/rt')
-rw-r--r--cli/rt/02_console.js13
-rw-r--r--cli/rt/11_streams.js7
-rw-r--r--cli/rt/11_url.js3
-rw-r--r--cli/rt/20_headers.js3
-rw-r--r--cli/rt/20_streams_queuing_strategy.js2
-rw-r--r--cli/rt/40_performance.js6
6 files changed, 22 insertions, 12 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)) {
diff --git a/cli/rt/11_streams.js b/cli/rt/11_streams.js
index 7f8af19e2..630878e74 100644
--- a/cli/rt/11_streams.js
+++ b/cli/rt/11_streams.js
@@ -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;
}
}
diff --git a/cli/rt/11_url.js b/cli/rt/11_url.js
index fee40ebcf..99f4ba0e1 100644
--- a/cli/rt/11_url.js
+++ b/cli/rt/11_url.js
@@ -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",
diff --git a/cli/rt/20_headers.js b/cli/rt/20_headers.js
index 7b9ef8c8e..ccde77e8d 100644
--- a/cli/rt/20_headers.js
+++ b/cli/rt/20_headers.js
@@ -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]) {
diff --git a/cli/rt/20_streams_queuing_strategy.js b/cli/rt/20_streams_queuing_strategy.js
index cbd30664f..af32c7d2e 100644
--- a/cli/rt/20_streams_queuing_strategy.js
+++ b/cli/rt/20_streams_queuing_strategy.js
@@ -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 }) {
diff --git a/cli/rt/40_performance.js b/cli/rt/40_performance.js
index 768c43a6a..a785d23b1 100644
--- a/cli/rt/40_performance.js
+++ b/cli/rt/40_performance.js
@@ -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} }`;
}