Skip to content

Commit 3966b69

Browse files
Paul-IsacheMylesBorins
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 4b9518d commit 3966b69

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
@@ -362,6 +362,10 @@ function getKeys(value, showHidden) {
362362
return keys;
363363
}
364364

365+
function getCtxStyle(constructor, tag) {
366+
return constructor || tag || 'Object';
367+
}
368+
365369
function formatProxy(ctx, proxy, recurseTimes) {
366370
if (recurseTimes != null) {
367371
if (recurseTimes < 0)
@@ -708,7 +712,7 @@ function formatRaw(ctx, value, recurseTimes) {
708712

709713
if (recurseTimes != null) {
710714
if (recurseTimes < 0)
711-
return ctx.stylize(`[${constructor || tag || 'Object'}]`, 'special');
715+
return ctx.stylize(`[${getCtxStyle(constructor, tag)}]`, 'special');
712716
recurseTimes -= 1;
713717
}
714718

@@ -746,7 +750,7 @@ function handleMaxCallStackSize(ctx, err, constructor, tag, indentationLvl) {
746750
ctx.seen.pop();
747751
ctx.indentationLvl = indentationLvl;
748752
return ctx.stylize(
749-
`[${constructor || tag || 'Object'}: Inspection interrupted ` +
753+
`[${getCtxStyle(constructor, tag)}: Inspection interrupted ` +
750754
'prematurely. Maximum call stack size exceeded.]',
751755
'special'
752756
);

0 commit comments

Comments
 (0)