lib: combine contructor, tag, Object into a function

combine these parts into a function to be used in multiple parts

PR-URL: https://github.com/nodejs/node/pull/24171
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This commit is contained in:
Paul Isache authored and Myles Borins committed 2018-12-26 11:18:53 -05:00
1 parent 4b9518dba3
commit 3966b698f6
1 file changed
+6 -2
+6 -2
View File
@@ -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)
@@ -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;
}
@@ -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'
);