Skip to content

Commit 6f80a45

Browse files
Paul-IsacheBridgeAR
authored andcommitted
lib: combine contructor, tag, Object into a function
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]>
1 parent 825f0dd commit 6f80a45

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/internal/util/inspect.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,10 @@ function getKeys(value, showHidden) {
400400
return keys;
401401
}
402402

403+
function getCtxStyle(constructor, tag) {
404+
return constructor || tag || 'Object';
405+
}
406+
403407
function formatProxy(ctx, proxy, recurseTimes) {
404408
if (recurseTimes != null) {
405409
if (recurseTimes < 0)
@@ -741,7 +745,7 @@ function formatRaw(ctx, value, recurseTimes) {
741745

742746
if (recurseTimes != null) {
743747
if (recurseTimes < 0)
744-
return ctx.stylize(`[${constructor || tag || 'Object'}]`, 'special');
748+
return ctx.stylize(`[${getCtxStyle(constructor, tag)}]`, 'special');
745749
recurseTimes -= 1;
746750
}
747751

@@ -793,7 +797,7 @@ function handleMaxCallStackSize(ctx, err, constructor, tag, indentationLvl) {
793797
ctx.seen.pop();
794798
ctx.indentationLvl = indentationLvl;
795799
return ctx.stylize(
796-
`[${constructor || tag || 'Object'}: Inspection interrupted ` +
800+
`[${getCtxStyle(constructor, tag)}: Inspection interrupted ` +
797801
'prematurely. Maximum call stack size exceeded.]',
798802
'special'
799803
);

0 commit comments

Comments
 (0)