Skip to content

Commit

Permalink
lib: combine contructor, tag, Object into a function
Browse files Browse the repository at this point in the history
combine these parts into a function to be used in multiple parts

PR-URL: #24171
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
  • Loading branch information
Paul-Isache authored and BridgeAR committed Nov 13, 2018
1 parent 825f0dd commit 6f80a45
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/internal/util/inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,10 @@ function getKeys(value, showHidden) {
return keys;
}

function getCtxStyle(constructor, tag) {
return constructor || tag || 'Object';
}

function formatProxy(ctx, proxy, recurseTimes) {
if (recurseTimes != null) {
if (recurseTimes < 0)
Expand Down Expand Up @@ -741,7 +745,7 @@ function formatRaw(ctx, value, recurseTimes) {

if (recurseTimes != null) {
if (recurseTimes < 0)
return ctx.stylize(`[${constructor || tag || 'Object'}]`, 'special');
return ctx.stylize(`[${getCtxStyle(constructor, tag)}]`, 'special');
recurseTimes -= 1;
}

Expand Down Expand Up @@ -793,7 +797,7 @@ function handleMaxCallStackSize(ctx, err, constructor, tag, indentationLvl) {
ctx.seen.pop();
ctx.indentationLvl = indentationLvl;
return ctx.stylize(
`[${constructor || tag || 'Object'}: Inspection interrupted ` +
`[${getCtxStyle(constructor, tag)}: Inspection interrupted ` +
'prematurely. Maximum call stack size exceeded.]',
'special'
);
Expand Down

0 comments on commit 6f80a45

Please sign in to comment.