util: simpler module namespace code
This removes a special casing for this data type in the main function. PR-URL: https://github.com/nodejs/node/pull/25255 Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
76fa37af75
commit
1ab659a141
@ -557,7 +557,6 @@ function formatRaw(ctx, value, recurseTimes, typedArray) {
|
|||||||
let braces;
|
let braces;
|
||||||
let noIterator = true;
|
let noIterator = true;
|
||||||
let i = 0;
|
let i = 0;
|
||||||
let skip = false;
|
|
||||||
const filter = ctx.showHidden ? ALL_PROPERTIES : ONLY_ENUMERABLE;
|
const filter = ctx.showHidden ? ALL_PROPERTIES : ONLY_ENUMERABLE;
|
||||||
|
|
||||||
let extrasType = kObjectType;
|
let extrasType = kObjectType;
|
||||||
@ -701,7 +700,6 @@ function formatRaw(ctx, value, recurseTimes, typedArray) {
|
|||||||
} else if (isModuleNamespaceObject(value)) {
|
} else if (isModuleNamespaceObject(value)) {
|
||||||
braces[0] = `[${tag}] {`;
|
braces[0] = `[${tag}] {`;
|
||||||
formatter = formatNamespaceObject;
|
formatter = formatNamespaceObject;
|
||||||
skip = true;
|
|
||||||
} else if (isBoxedPrimitive(value)) {
|
} else if (isBoxedPrimitive(value)) {
|
||||||
let type;
|
let type;
|
||||||
if (isNumberObject(value)) {
|
if (isNumberObject(value)) {
|
||||||
@ -761,12 +759,10 @@ function formatRaw(ctx, value, recurseTimes, typedArray) {
|
|||||||
const indentationLvl = ctx.indentationLvl;
|
const indentationLvl = ctx.indentationLvl;
|
||||||
try {
|
try {
|
||||||
output = formatter(ctx, value, recurseTimes, keys);
|
output = formatter(ctx, value, recurseTimes, keys);
|
||||||
if (skip === false) {
|
|
||||||
for (i = 0; i < keys.length; i++) {
|
for (i = 0; i < keys.length; i++) {
|
||||||
output.push(
|
output.push(
|
||||||
formatProperty(ctx, value, recurseTimes, keys[i], extrasType));
|
formatProperty(ctx, value, recurseTimes, keys[i], extrasType));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return handleMaxCallStackSize(ctx, err, constructor, tag, indentationLvl);
|
return handleMaxCallStackSize(ctx, err, constructor, tag, indentationLvl);
|
||||||
}
|
}
|
||||||
@ -875,9 +871,8 @@ function formatError(value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function formatNamespaceObject(ctx, value, recurseTimes, keys) {
|
function formatNamespaceObject(ctx, value, recurseTimes, keys) {
|
||||||
const len = keys.length;
|
const output = new Array(keys.length);
|
||||||
const output = new Array(len);
|
for (var i = 0; i < keys.length; i++) {
|
||||||
for (var i = 0; i < len; i++) {
|
|
||||||
try {
|
try {
|
||||||
output[i] = formatProperty(ctx, value, recurseTimes, keys[i],
|
output[i] = formatProperty(ctx, value, recurseTimes, keys[i],
|
||||||
kObjectType);
|
kObjectType);
|
||||||
@ -897,6 +892,8 @@ function formatNamespaceObject(ctx, value, recurseTimes, keys) {
|
|||||||
ctx.stylize('<uninitialized>', 'special');
|
ctx.stylize('<uninitialized>', 'special');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Reset the keys to an empty array. This prevents duplicated inspection.
|
||||||
|
keys.length = 0;
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user