diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js index 0ff86d92970ca5..742e66e1efd1ef 100644 --- a/lib/internal/util/inspect.js +++ b/lib/internal/util/inspect.js @@ -104,9 +104,6 @@ const { } = require('internal/util'); const { - codes: { - ERR_INVALID_ARG_TYPE - }, isStackOverflowError } = require('internal/errors'); @@ -2101,10 +2098,7 @@ function format(...args) { } function formatWithOptions(inspectOptions, ...args) { - if (typeof inspectOptions !== 'object' || inspectOptions === null) { - throw new ERR_INVALID_ARG_TYPE( - 'inspectOptions', 'object', inspectOptions); - } + validateObject(inspectOptions, 'inspectOptions'); return formatWithOptionsInternal(inspectOptions, args); } diff --git a/test/parallel/test-util-format.js b/test/parallel/test-util-format.js index ab0d50f743fd98..edab2930ea556d 100644 --- a/test/parallel/test-util-format.js +++ b/test/parallel/test-util-format.js @@ -524,6 +524,7 @@ assert.strictEqual( 5, 'test', Symbol(), + [], ].forEach((invalidOptions) => { assert.throws(() => { util.formatWithOptions(invalidOptions, { a: true });