Skip to content

Commit 4d083aa

Browse files
committed
fixup! fixup! repl: refactor to avoid unsafe array iteration
1 parent f1f9f77 commit 4d083aa

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/internal/util/inspect.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -309,16 +309,17 @@ function inspect(value, opts) {
309309
if (typeof opts === 'boolean') {
310310
ctx.showHidden = opts;
311311
} else if (opts) {
312-
const optKeys = ObjectKeys(opts);
313-
for (const key of optKeys) {
312+
for (const key in opts) {
314313
// TODO(BridgeAR): Find a solution what to do about stylize. Either make
315314
// this function public or add a new API with a similar or better
316315
// functionality.
317316
if (
318317
ObjectPrototypeHasOwnProperty(inspectDefaultOptions, key) ||
319318
key === 'stylize') {
320319
ctx[key] = opts[key];
321-
} else if (ctx.userOptions === undefined) {
320+
} else if (
321+
ObjectPrototypeHasOwnProperty(opts, key) &&
322+
ctx.userOptions === undefined) {
322323
// This is required to pass through the actual user input.
323324
ctx.userOptions = opts;
324325
}

0 commit comments

Comments
 (0)