Skip to content

Commit 70e89c4

Browse files
lib: update inspect output format for subclasses
1 parent 4612c79 commit 70e89c4

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
@@ -1031,7 +1031,7 @@ function getPrefix(constructor, tag, fallback, size = '') {
10311031
return `[${fallback}${size}: null prototype] `;
10321032
}
10331033

1034-
if (tag !== '' && constructor !== tag) {
1034+
if (tag !== '' && !constructor.includes(tag)) {
10351035
return `${constructor}${size} [${tag}] `;
10361036
}
10371037
return `${constructor}${size} `;
@@ -1507,7 +1507,7 @@ function getClassBase(value, constructor, tag) {
15071507
if (constructor !== 'Function' && constructor !== null) {
15081508
base += ` [${constructor}]`;
15091509
}
1510-
if (tag !== '' && constructor !== tag) {
1510+
if (tag !== '' && (constructor === null || !constructor.includes(tag))) {
15111511
base += ` [${tag}]`;
15121512
}
15131513
if (constructor !== null) {
@@ -1554,7 +1554,7 @@ function getFunctionBase(ctx, value, constructor, tag) {
15541554
if (constructor !== type && constructor !== null) {
15551555
base += ` ${constructor}`;
15561556
}
1557-
if (tag !== '' && constructor !== tag) {
1557+
if (tag !== '' && (constructor === null || !constructor.includes(tag))) {
15581558
base += ` [${tag}]`;
15591559
}
15601560
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)