mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
lib: don't use util.inspect()
internals
This makes sure the internal `stylize` function is not used to render anything and instead just uses the regular inspect function in case of reaching the maximum depth level. PR-URL: https://github.com/nodejs/node/pull/24971 Refs: https://github.com/nodejs/node/issues/24765 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
parent
6c52ef9825
commit
be78266fb3
@ -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
|
||||
|
@ -343,7 +343,7 @@ class URL {
|
||||
}
|
||||
|
||||
if (typeof depth === 'number' && depth < 0)
|
||||
return opts.stylize('[Object]', 'special');
|
||||
return this;
|
||||
|
||||
var ctor = getConstructorOf(this);
|
||||
|
||||
|
@ -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]');
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -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 {'));
|
||||
|
Loading…
Reference in New Issue
Block a user