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
25 changes: 19 additions & 6 deletions lib/internal/util/inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -1539,13 +1539,18 @@ function getBoxedBase(value, ctx, keys, constructor, tag) {
base += ` (${constructor})`;
}
}
base += `: ${formatPrimitive(stylizeNoColor, fn(value), ctx)}]`;
if (tag !== '' && tag !== constructor) {
base += ` [${tag}]`;
}
if (keys.length !== 0 || ctx.stylize === stylizeNoColor)
return base;
return ctx.stylize(base, StringPrototypeToLowerCase(type));
if (constructor !== null) {
const superName = ObjectGetPrototypeOf(value).name;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why would a [[Prototype]] object necessarily have a .name? and why would a class-related change belong in a PR fixing number display?

if (superName) {
base += ` extends ${superName}`;
}
} else {
base += ' extends [null prototype]';
}
return `${base}: ${formatPrimitive(stylizeNoColor, fn(value), ctx)}]`;
}

function getClassBase(value, constructor, tag) {
Expand Down Expand Up @@ -1835,7 +1840,7 @@ function improveStack(stack, constructor, name, tag) {
}
const prefix = StringPrototypeSlice(getPrefix(constructor, tag, fallback), 0, -1);
if (name !== prefix) {
if (StringPrototypeIncludes(prefix, name)) {
if (StringPrototypeSlice(prefix, -len) === name) {
if (len === 0) {
stack = `${prefix}: ${stack}`;
} else {
Expand Down Expand Up @@ -2204,12 +2209,20 @@ function formatNumber(fn, number, numericSeparator) {
if (!NumberIsFinite(number) || StringPrototypeIncludes(numberString, 'e')) {
return fn(numberString, 'number');
}
if (StringPrototypeIncludes(numberString, 'e')) {
return fn(numberString, 'number');
}
return fn(addNumericSeparator(numberString), 'number');
}
if (NumberIsNaN(number)) {
return fn(numberString, 'number');
}

// Scientific notation cannot have numeric separators applied sensibly
if (StringPrototypeIncludes(numberString, 'e')) {
return fn(numberString, 'number');
}

const decimalIndex = StringPrototypeIndexOf(numberString, '.');
const integerPart = StringPrototypeSlice(numberString, 0, decimalIndex);
const fractionalPart = StringPrototypeSlice(numberString, decimalIndex + 1);
Expand Down Expand Up @@ -2414,8 +2427,8 @@ function formatMap(value, ctx, ignored, recurseTimes) {
const maxLength = MathMin(MathMax(0, ctx.maxArrayLength), length);
const remaining = length - maxLength;
const output = [];
ctx.indentationLvl += 2;
let i = 0;
ctx.indentationLvl += 2;
Comment on lines -2417 to +2431
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls revert this, it's unrelated

for (const { 0: k, 1: v } of value) {
if (i >= maxLength) break;
ArrayPrototypePush(
Expand Down
Loading