Skip to content

Commit 98e72c1

Browse files
lib: update inspect output format for subclasses
1 parent 538186b commit 98e72c1

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

lib/internal/util/inspect.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@ function getPrefix(constructor, tag, fallback, size = '') {
780780
return `[${fallback}${size}: null prototype] `;
781781
}
782782

783-
if (tag !== '' && constructor !== tag) {
783+
if (tag !== '' && !constructor.includes(tag)) {
784784
return `${constructor}${size} [${tag}] `;
785785
}
786786
return `${constructor}${size} `;
@@ -1248,7 +1248,7 @@ function getClassBase(value, constructor, tag) {
12481248
if (constructor !== 'Function' && constructor !== null) {
12491249
base += ` [${constructor}]`;
12501250
}
1251-
if (tag !== '' && constructor !== tag) {
1251+
if (tag !== '' && (constructor === null || !constructor.includes(tag))) {
12521252
base += ` [${tag}]`;
12531253
}
12541254
if (constructor !== null) {
@@ -1295,7 +1295,7 @@ function getFunctionBase(ctx, value, constructor, tag) {
12951295
if (constructor !== type && constructor !== null) {
12961296
base += ` ${constructor}`;
12971297
}
1298-
if (tag !== '' && constructor !== tag) {
1298+
if (tag !== '' && (constructor === null || !constructor.includes(tag))) {
12991299
base += ` [${tag}]`;
13001300
}
13011301
return base;

test/parallel/test-util-inspect.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,11 +1415,11 @@ if (typeof Symbol !== 'undefined') {
14151415
assert.strictEqual(util.inspect(new ArraySubclass(1, 2, 3)),
14161416
'ArraySubclass(3) [ 1, 2, 3 ]');
14171417
assert.strictEqual(util.inspect(new SetSubclass([1, 2, 3])),
1418-
'SetSubclass(3) [Set] { 1, 2, 3 }');
1418+
'SetSubclass(3) { 1, 2, 3 }');
14191419
assert.strictEqual(util.inspect(new MapSubclass([['foo', 42]])),
1420-
"MapSubclass(1) [Map] { 'foo' => 42 }");
1420+
"MapSubclass(1) { 'foo' => 42 }");
14211421
assert.strictEqual(util.inspect(new PromiseSubclass(() => {})),
1422-
'PromiseSubclass [Promise] { <pending> }');
1422+
'PromiseSubclass { <pending> }');
14231423
assert.strictEqual(util.inspect(new SymbolNameClass()),
14241424
'Symbol(name) {}');
14251425
assert.strictEqual(

0 commit comments

Comments
 (0)