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 2018-11-06 15:57:45 +00:00 committed by Anna Henningsen
parent 8793e0de1d
commit 04ccc98de6
No known key found for this signature in database
GPG Key ID: 9C63F3A6CD2AD8F9

View File

@ -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)
@ -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;
}
@ -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'
);