Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
lib: update inspect output format for subclasses
  • Loading branch information
miguelmarcondesf committed Sep 19, 2025
commit 70e89c40341a262bc13d041a46887f81972f8110
6 changes: 3 additions & 3 deletions lib/internal/util/inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -1031,7 +1031,7 @@ function getPrefix(constructor, tag, fallback, size = '') {
return `[${fallback}${size}: null prototype] `;
}

if (tag !== '' && constructor !== tag) {
if (tag !== '' && !constructor.includes(tag)) {
return `${constructor}${size} [${tag}] `;
}
return `${constructor}${size} `;
Expand Down Expand Up @@ -1507,7 +1507,7 @@ function getClassBase(value, constructor, tag) {
if (constructor !== 'Function' && constructor !== null) {
base += ` [${constructor}]`;
}
if (tag !== '' && constructor !== tag) {
if (tag !== '' && (constructor === null || !constructor.includes(tag))) {
base += ` [${tag}]`;
}
if (constructor !== null) {
Expand Down Expand Up @@ -1554,7 +1554,7 @@ function getFunctionBase(ctx, value, constructor, tag) {
if (constructor !== type && constructor !== null) {
base += ` ${constructor}`;
}
if (tag !== '' && constructor !== tag) {
if (tag !== '' && (constructor === null || !constructor.includes(tag))) {
base += ` [${tag}]`;
}
return base;
Expand Down
6 changes: 3 additions & 3 deletions test/parallel/test-util-inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -1415,11 +1415,11 @@ if (typeof Symbol !== 'undefined') {
assert.strictEqual(util.inspect(new ArraySubclass(1, 2, 3)),
'ArraySubclass(3) [ 1, 2, 3 ]');
assert.strictEqual(util.inspect(new SetSubclass([1, 2, 3])),
'SetSubclass(3) [Set] { 1, 2, 3 }');
'SetSubclass(3) { 1, 2, 3 }');
assert.strictEqual(util.inspect(new MapSubclass([['foo', 42]])),
"MapSubclass(1) [Map] { 'foo' => 42 }");
"MapSubclass(1) { 'foo' => 42 }");
assert.strictEqual(util.inspect(new PromiseSubclass(() => {})),
'PromiseSubclass [Promise] { <pending> }');
'PromiseSubclass { <pending> }');
assert.strictEqual(util.inspect(new SymbolNameClass()),
'Symbol(name) {}');
assert.strictEqual(
Expand Down