lib: don't use util.inspect() internals · nodejs/node@be78266 (original) (raw)

4 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -320,7 +320,7 @@ class TextEncoder {
320 320 [inspect](depth, opts) {
321 321 validateEncoder(this);
322 322 if (typeof depth === 'number' && depth < 0)
323 -return opts.stylize('[Object]', 'special');
323 +return this;
324 324 var ctor = getConstructorOf(this);
325 325 var obj = Object.create({
326 326 constructor: ctor === null ? TextEncoder : ctor
@@ -517,7 +517,7 @@ function makeTextDecoderJS() {
517 517 [inspect](depth, opts) {
518 518 validateDecoder(this);
519 519 if (typeof depth === 'number' && depth < 0)
520 -return opts.stylize('[Object]', 'special');
520 +return this;
521 521 var ctor = getConstructorOf(this);
522 522 var obj = Object.create({
523 523 constructor: ctor === null ? TextDecoder : ctor
Original file line number Diff line number Diff line change
@@ -343,7 +343,7 @@ class URL {
343 343 }
344 344
345 345 if (typeof depth === 'number' && depth < 0)
346 -return opts.stylize('[Object]', 'special');
346 +return this;
347 347
348 348 var ctor = getConstructorOf(this);
349 349
Original file line number Diff line number Diff line change
@@ -134,7 +134,7 @@ if (common.hasIntl) {
134 134 // Test TextDecoder inspect with negative depth
135 135 {
136 136 const dec = new TextDecoder();
137 -assert.strictEqual(util.inspect(dec, { depth: -1 }), '[Object]');
137 +assert.strictEqual(util.inspect(dec, { depth: -1 }), '[TextDecoder]');
138 138 }
139 139
140 140 {
Original file line number Diff line number Diff line change
@@ -63,7 +63,7 @@ assert.strictEqual(
63 63
64 64 assert.strictEqual(
65 65 util.inspect({ a: url }, { depth: 0 }),
66 -'{ a: [Object] }');
66 +'{ a: [URL] }');
67 67
68 68 class MyURL extends URL {}
69 69 assert(util.inspect(new MyURL(url.href)).startsWith('MyURL {'));