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 <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
  • Loading branch information
Paul-Isache authored and MylesBorins committed Dec 26, 2018
1 parent 4b9518d commit 3966b69
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/internal/util/inspect.js
Expand Up @@ -362,6 +362,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 @@ -708,7 +712,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 @@ -746,7 +750,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 3966b69

Please sign in to comment.