summaryrefslogtreecommitdiff
path: root/lib/internal/util/inspect.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/internal/util/inspect.js')
-rw-r--r--lib/internal/util/inspect.js8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js
index 9099c33e9e..9a1a0f9f03 100644
--- a/lib/internal/util/inspect.js
+++ b/lib/internal/util/inspect.js
@@ -516,10 +516,14 @@ function formatValue(ctx, value, recurseTimes, typedArray) {
maybeCustom !== inspect &&
// Also filter out any prototype objects using the circular check.
!(value.constructor && value.constructor.prototype === value)) {
+ // Remove some internal properties from the options before passing it
+ // through to the user function. This also prevents option manipulation.
+ // eslint-disable-next-line no-unused-vars
+ const { budget, seen, indentationLvl, ...plainCtx } = ctx;
// This makes sure the recurseTimes are reported as before while using
// a counter internally.
const depth = ctx.depth === null ? null : ctx.depth - recurseTimes;
- const ret = maybeCustom.call(value, depth, ctx);
+ const ret = maybeCustom.call(value, depth, plainCtx);
// If the custom inspection method returned `this`, don't go into
// infinite recursion.
@@ -527,7 +531,7 @@ function formatValue(ctx, value, recurseTimes, typedArray) {
if (typeof ret !== 'string') {
return formatValue(ctx, ret, recurseTimes);
}
- return ret;
+ return ret.replace(/\n/g, `\n${' '.repeat(ctx.indentationLvl)}`);
}
}
}