diff options
Diffstat (limited to 'ext/websocket')
-rw-r--r-- | ext/websocket/01_websocket.js | 32 | ||||
-rw-r--r-- | ext/websocket/02_websocketstream.js | 20 |
2 files changed, 35 insertions, 17 deletions
diff --git a/ext/websocket/01_websocket.js b/ext/websocket/01_websocket.js index 752ff93bd..a4e6b71a3 100644 --- a/ext/websocket/01_websocket.js +++ b/ext/websocket/01_websocket.js @@ -5,6 +5,7 @@ const core = globalThis.Deno.core; import { URL } from "ext:deno_url/00_url.js"; import * as webidl from "ext:deno_webidl/00_webidl.js"; +import { createFilteredInspectProxy } from "ext:deno_console/01_console.js"; import { HTTP_TOKEN_CODE_POINT_RE } from "ext:deno_web/00_infra.js"; import DOMException from "ext:deno_web/01_dom_exception.js"; import { @@ -536,17 +537,26 @@ class WebSocket extends EventTarget { } } - [SymbolFor("Deno.customInspect")](inspect) { - return `${this.constructor.name} ${ - inspect({ - url: this.url, - readyState: this.readyState, - extensions: this.extensions, - protocol: this.protocol, - binaryType: this.binaryType, - bufferedAmount: this.bufferedAmount, - }) - }`; + [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) { + return inspect( + createFilteredInspectProxy({ + object: this, + evaluate: ObjectPrototypeIsPrototypeOf(WebSocketPrototype, this), + keys: [ + "url", + "readyState", + "extensions", + "protocol", + "binaryType", + "bufferedAmount", + "onmessage", + "onerror", + "onclose", + "onopen", + ], + }), + inspectOptions, + ); } } diff --git a/ext/websocket/02_websocketstream.js b/ext/websocket/02_websocketstream.js index d4c960338..ff24a72af 100644 --- a/ext/websocket/02_websocketstream.js +++ b/ext/websocket/02_websocketstream.js @@ -5,6 +5,7 @@ const core = globalThis.Deno.core; const ops = core.ops; import * as webidl from "ext:deno_webidl/00_webidl.js"; +import { createFilteredInspectProxy } from "ext:deno_console/01_console.js"; import { Deferred, writableStreamClose } from "ext:deno_web/06_streams.js"; import DOMException from "ext:deno_web/01_dom_exception.js"; import { add, remove } from "ext:deno_web/03_abort_signal.js"; @@ -423,12 +424,19 @@ class WebSocketStream { } } - [SymbolFor("Deno.customInspect")](inspect) { - return `${this.constructor.name} ${ - inspect({ - url: this.url, - }) - }`; + [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) { + return inspect( + createFilteredInspectProxy({ + object: this, + evaluate: ObjectPrototypeIsPrototypeOf(WebSocketStreamPrototype, this), + keys: [ + "closed", + "opened", + "url", + ], + }), + inspectOptions, + ); } } |