From c806fbdabe144c865612bbbc9ef596c9611c8310 Mon Sep 17 00:00:00 2001 From: Kenta Moriuchi Date: Sun, 19 Nov 2023 17:13:38 +0900 Subject: fix(ext,runtime): add missing custom inspections (#21219) --- ext/web/03_abort_signal.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'ext/web/03_abort_signal.js') diff --git a/ext/web/03_abort_signal.js b/ext/web/03_abort_signal.js index a237b273c..f534ec04f 100644 --- a/ext/web/03_abort_signal.js +++ b/ext/web/03_abort_signal.js @@ -5,6 +5,7 @@ import * as webidl from "ext:deno_webidl/00_webidl.js"; import { assert } from "ext:deno_web/00_infra.js"; +import { createFilteredInspectProxy } from "ext:deno_console/01_console.js"; import { defineEventHandler, Event, @@ -16,6 +17,7 @@ const primordials = globalThis.__bootstrap.primordials; const { ArrayPrototypeEvery, ArrayPrototypePush, + ObjectPrototypeIsPrototypeOf, SafeArrayIterator, SafeSet, SafeSetIterator, @@ -24,6 +26,7 @@ const { SetPrototypeAdd, SetPrototypeDelete, Symbol, + SymbolFor, TypeError, WeakRefPrototypeDeref, WeakSetPrototypeAdd, @@ -238,6 +241,21 @@ class AbortSignal extends EventTarget { } } } + + [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) { + return inspect( + createFilteredInspectProxy({ + object: this, + evaluate: ObjectPrototypeIsPrototypeOf(AbortSignalPrototype, this), + keys: [ + "aborted", + "reason", + "onabort", + ], + }), + inspectOptions, + ); + } } defineEventHandler(AbortSignal.prototype, "abort"); @@ -260,6 +278,19 @@ class AbortController { webidl.assertBranded(this, AbortControllerPrototype); this[signal][signalAbort](reason); } + + [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) { + return inspect( + createFilteredInspectProxy({ + object: this, + evaluate: ObjectPrototypeIsPrototypeOf(AbortControllerPrototype, this), + keys: [ + "signal", + ], + }), + inspectOptions, + ); + } } webidl.configureInterface(AbortController); -- cgit v1.2.3