Skip to content
Open
Changes from all commits
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
13 changes: 2 additions & 11 deletions lib/internal/util/inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -1173,17 +1173,8 @@ function formatValue(ctx, value, recurseTimes, typedArray) {
// Using an array here is actually better for the average case than using
// a Set. `seen` will only check for the depth and will never grow too large.
if (ctx.seen.includes(value)) {
let index = 1;
if (ctx.circular === undefined) {
ctx.circular = new SafeMap();
ctx.circular.set(value, index);
} else {
index = ctx.circular.get(value);
if (index === undefined) {
index = ctx.circular.size + 1;
ctx.circular.set(value, index);
}
}
ctx.circular ??= new SafeMap();
const index = ctx.circular.getOrInsert(value, ctx.circular.size + 1);
return ctx.stylize(`[Circular *${index}]`, 'special');
}

Expand Down
Loading