Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 45a8eb6

Browse filesBrowse files
BridgeARaddaleax
authored andcommitted
util: simpler module namespace code
This removes a special casing for this data type in the main function. PR-URL: #25255 Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent a333272 commit 45a8eb6
Copy full SHA for 45a8eb6

File tree

Expand file treeCollapse file tree

1 file changed

+7
-10
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+7
-10
lines changed
Open diff view settings
Collapse file

‎lib/internal/util/inspect.js‎

Copy file name to clipboardExpand all lines: lib/internal/util/inspect.js
+7-10Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,6 @@ function formatRaw(ctx, value, recurseTimes, typedArray) {
557557
let braces;
558558
let noIterator = true;
559559
let i = 0;
560-
let skip = false;
561560
const filter = ctx.showHidden ? ALL_PROPERTIES : ONLY_ENUMERABLE;
562561

563562
let extrasType = kObjectType;
@@ -701,7 +700,6 @@ function formatRaw(ctx, value, recurseTimes, typedArray) {
701700
} else if (isModuleNamespaceObject(value)) {
702701
braces[0] = `[${tag}] {`;
703702
formatter = formatNamespaceObject;
704-
skip = true;
705703
} else if (isBoxedPrimitive(value)) {
706704
let type;
707705
if (isNumberObject(value)) {
@@ -761,11 +759,9 @@ function formatRaw(ctx, value, recurseTimes, typedArray) {
761759
const indentationLvl = ctx.indentationLvl;
762760
try {
763761
output = formatter(ctx, value, recurseTimes, keys);
764-
if (skip === false) {
765-
for (i = 0; i < keys.length; i++) {
766-
output.push(
767-
formatProperty(ctx, value, recurseTimes, keys[i], extrasType));
768-
}
762+
for (i = 0; i < keys.length; i++) {
763+
output.push(
764+
formatProperty(ctx, value, recurseTimes, keys[i], extrasType));
769765
}
770766
} catch (err) {
771767
return handleMaxCallStackSize(ctx, err, constructor, tag, indentationLvl);
@@ -875,9 +871,8 @@ function formatError(value) {
875871
}
876872

877873
function formatNamespaceObject(ctx, value, recurseTimes, keys) {
878-
const len = keys.length;
879-
const output = new Array(len);
880-
for (var i = 0; i < len; i++) {
874+
const output = new Array(keys.length);
875+
for (var i = 0; i < keys.length; i++) {
881876
try {
882877
output[i] = formatProperty(ctx, value, recurseTimes, keys[i],
883878
kObjectType);
@@ -897,6 +892,8 @@ function formatNamespaceObject(ctx, value, recurseTimes, keys) {
897892
ctx.stylize('<uninitialized>', 'special');
898893
}
899894
}
895+
// Reset the keys to an empty array. This prevents duplicated inspection.
896+
keys.length = 0;
900897
return output;
901898
}
902899

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.