Skip to content
Closed
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
Prev Previous commit
Next Next commit
util: simpler module namespace code
This removes a special casing for this data type in the main function.
  • Loading branch information
BridgeAR committed Dec 28, 2018
commit 65cad907580b2f36927b60e30593d5fe9c69da7b
17 changes: 7 additions & 10 deletions lib/internal/util/inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,6 @@ function formatRaw(ctx, value, recurseTimes) {
let braces;
let noIterator = true;
let i = 0;
let skip = false;
const filter = ctx.showHidden ? ALL_PROPERTIES : ONLY_ENUMERABLE;

let extrasType = kObjectType;
Expand Down Expand Up @@ -690,7 +689,6 @@ function formatRaw(ctx, value, recurseTimes) {
} else if (isModuleNamespaceObject(value)) {
braces[0] = `[${tag}] {`;
formatter = formatNamespaceObject;
skip = true;
} else if (isBoxedPrimitive(value)) {
let type;
if (isNumberObject(value)) {
Expand Down Expand Up @@ -750,11 +748,9 @@ function formatRaw(ctx, value, recurseTimes) {
const indentationLvl = ctx.indentationLvl;
try {
output = formatter(ctx, value, recurseTimes, keys);
if (skip === false) {
for (i = 0; i < keys.length; i++) {
output.push(
formatProperty(ctx, value, recurseTimes, keys[i], extrasType));
}
for (i = 0; i < keys.length; i++) {
output.push(
formatProperty(ctx, value, recurseTimes, keys[i], extrasType));
}
} catch (err) {
return handleMaxCallStackSize(ctx, err, constructor, tag, indentationLvl);
Expand Down Expand Up @@ -864,9 +860,8 @@ function formatError(value) {
}

function formatNamespaceObject(ctx, value, recurseTimes, keys) {
const len = keys.length;
const output = new Array(len);
for (var i = 0; i < len; i++) {
const output = new Array(keys.length);
for (var i = 0; i < keys.length; i++) {
try {
output[i] = formatProperty(ctx, value, recurseTimes, keys[i],
kObjectType);
Expand All @@ -886,6 +881,8 @@ function formatNamespaceObject(ctx, value, recurseTimes, keys) {
ctx.stylize('<uninitialized>', 'special');
}
}
// Reset the keys to an empty array. This prevents duplicated inspection.
keys.length = 0;
return output;
}

Expand Down