diff options
author | Kenta Moriuchi <moriken@kimamass.com> | 2023-11-19 17:13:38 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-19 09:13:38 +0100 |
commit | c806fbdabe144c865612bbbc9ef596c9611c8310 (patch) | |
tree | edb38d58720377580677ccbeffb693ffa1225cc4 /ext/fetch/20_headers.js | |
parent | a7548afb58b9848e501a085455446f5de897ffaa (diff) |
fix(ext,runtime): add missing custom inspections (#21219)
Diffstat (limited to 'ext/fetch/20_headers.js')
-rw-r--r-- | ext/fetch/20_headers.js | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/ext/fetch/20_headers.js b/ext/fetch/20_headers.js index b99758de5..d03751d08 100644 --- a/ext/fetch/20_headers.js +++ b/ext/fetch/20_headers.js @@ -26,7 +26,9 @@ const { ArrayPrototypeSort, ArrayPrototypeJoin, ArrayPrototypeSplice, + ObjectFromEntries, ObjectHasOwn, + ObjectPrototypeIsPrototypeOf, RegExpPrototypeTest, Symbol, SymbolFor, @@ -441,13 +443,14 @@ class Headers { } } - [SymbolFor("Deno.privateCustomInspect")](inspect) { - const headers = {}; - // deno-lint-ignore prefer-primordials - for (const header of this) { - headers[header[0]] = header[1]; + [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) { + if (ObjectPrototypeIsPrototypeOf(HeadersPrototype, this)) { + return `${this.constructor.name} ${ + inspect(ObjectFromEntries(this), inspectOptions) + }`; + } else { + return `${this.constructor.name} ${inspect({}, inspectOptions)}`; } - return `Headers ${inspect(headers)}`; } } |