Skip to content

Commit

Permalink
util: rename setIteratorBraces to getIteratorBraces
Browse files Browse the repository at this point in the history
The function is actually a getter, not a setter.

PR-URL: #27342
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
  • Loading branch information
BridgeAR authored and targos committed Apr 27, 2019
1 parent 973d705 commit 8f34428
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions lib/internal/util/inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -560,15 +560,6 @@ function formatValue(ctx, value, recurseTimes, typedArray) {
return formatRaw(ctx, value, recurseTimes, typedArray);
}

function setIteratorBraces(type, tag) {
if (tag !== `${type} Iterator`) {
if (tag !== '')
tag += '] [';
tag += `${type} Iterator`;
}
return [`[${tag}] {`, '}'];
}

function formatRaw(ctx, value, recurseTimes, typedArray) {
let keys;

Expand Down Expand Up @@ -630,11 +621,11 @@ function formatRaw(ctx, value, recurseTimes, typedArray) {
extrasType = kArrayExtrasType;
} else if (isMapIterator(value)) {
keys = getKeys(value, ctx.showHidden);
braces = setIteratorBraces('Map', tag);
braces = getIteratorBraces('Map', tag);
formatter = formatIterator;
} else if (isSetIterator(value)) {
keys = getKeys(value, ctx.showHidden);
braces = setIteratorBraces('Set', tag);
braces = getIteratorBraces('Set', tag);
formatter = formatIterator;
} else {
noIterator = true;
Expand Down Expand Up @@ -754,10 +745,10 @@ function formatRaw(ctx, value, recurseTimes, typedArray) {
}
}
if (isMapIterator(value)) {
braces = setIteratorBraces('Map', tag);
braces = getIteratorBraces('Map', tag);
formatter = formatIterator;
} else if (isSetIterator(value)) {
braces = setIteratorBraces('Set', tag);
braces = getIteratorBraces('Set', tag);
formatter = formatIterator;
// Handle other regular objects again.
} else if (keys.length === 0) {
Expand Down Expand Up @@ -818,6 +809,15 @@ function formatRaw(ctx, value, recurseTimes, typedArray) {
return res;
}

function getIteratorBraces(type, tag) {
if (tag !== `${type} Iterator`) {
if (tag !== '')
tag += '] [';
tag += `${type} Iterator`;
}
return [`[${tag}] {`, '}'];
}

function formatError(err, constructor, tag, ctx) {
// TODO(BridgeAR): Always show the error code if present.
let stack = err.stack || ErrorPrototype.toString(err);
Expand Down

0 comments on commit 8f34428

Please sign in to comment.