diff --git a/lib/internal/encoding.js b/lib/internal/encoding.js index 0084c19b904a82..3fbbbe1a2fefbd 100644 --- a/lib/internal/encoding.js +++ b/lib/internal/encoding.js @@ -320,7 +320,7 @@ class TextEncoder { [inspect](depth, opts) { validateEncoder(this); if (typeof depth === 'number' && depth < 0) - return opts.stylize('[Object]', 'special'); + return this; var ctor = getConstructorOf(this); var obj = Object.create({ constructor: ctor === null ? TextEncoder : ctor @@ -517,7 +517,7 @@ function makeTextDecoderJS() { [inspect](depth, opts) { validateDecoder(this); if (typeof depth === 'number' && depth < 0) - return opts.stylize('[Object]', 'special'); + return this; var ctor = getConstructorOf(this); var obj = Object.create({ constructor: ctor === null ? TextDecoder : ctor diff --git a/lib/internal/url.js b/lib/internal/url.js index 81a4966288657e..9727133ad1dd62 100644 --- a/lib/internal/url.js +++ b/lib/internal/url.js @@ -343,7 +343,7 @@ class URL { } if (typeof depth === 'number' && depth < 0) - return opts.stylize('[Object]', 'special'); + return this; var ctor = getConstructorOf(this); diff --git a/test/parallel/test-whatwg-encoding-custom-textdecoder.js b/test/parallel/test-whatwg-encoding-custom-textdecoder.js index ceee5b9cbbde30..63abd2506a5701 100644 --- a/test/parallel/test-whatwg-encoding-custom-textdecoder.js +++ b/test/parallel/test-whatwg-encoding-custom-textdecoder.js @@ -134,7 +134,7 @@ if (common.hasIntl) { // Test TextDecoder inspect with negative depth { const dec = new TextDecoder(); - assert.strictEqual(util.inspect(dec, { depth: -1 }), '[Object]'); + assert.strictEqual(util.inspect(dec, { depth: -1 }), '[TextDecoder]'); } { diff --git a/test/parallel/test-whatwg-url-custom-inspect.js b/test/parallel/test-whatwg-url-custom-inspect.js index 1083866d86f505..21c13582254e94 100644 --- a/test/parallel/test-whatwg-url-custom-inspect.js +++ b/test/parallel/test-whatwg-url-custom-inspect.js @@ -63,7 +63,7 @@ assert.strictEqual( assert.strictEqual( util.inspect({ a: url }, { depth: 0 }), - '{ a: [Object] }'); + '{ a: [URL] }'); class MyURL extends URL {} assert(util.inspect(new MyURL(url.href)).startsWith('MyURL {'));