diff options
Diffstat (limited to 'lib/internal/util/inspect.js')
-rw-r--r-- | lib/internal/util/inspect.js | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js index dde2066294..3664c15484 100644 --- a/lib/internal/util/inspect.js +++ b/lib/internal/util/inspect.js @@ -119,6 +119,8 @@ const builtInObjects = new Set( ObjectGetOwnPropertyNames(global).filter((e) => /^([A-Z][a-z]+)+$/.test(e)) ); +// These options must stay in sync with `getUserOptions`. So if any option will +// be added or removed, `getUserOptions` must also be updated accordingly. const inspectDefaultOptions = ObjectSeal({ showHidden: false, depth: 2, @@ -176,13 +178,20 @@ const meta = [ ]; function getUserOptions(ctx) { - const obj = { stylize: ctx.stylize }; - for (const key of ObjectKeys(inspectDefaultOptions)) { - obj[key] = ctx[key]; - } - if (ctx.userOptions === undefined) - return obj; - return { ...obj, ...ctx.userOptions }; + return { + stylize: ctx.stylize, + showHidden: ctx.showHidden, + depth: ctx.depth, + colors: ctx.colors, + customInspect: ctx.customInspect, + showProxy: ctx.showProxy, + maxArrayLength: ctx.maxArrayLength, + breakLength: ctx.breakLength, + compact: ctx.compact, + sorted: ctx.sorted, + getters: ctx.getters, + ...ctx.userOptions + }; } /** |