Skip to content

Commit

Permalink
util: refactor to use validateObject
Browse files Browse the repository at this point in the history
  • Loading branch information
cola119 committed Jul 11, 2022
1 parent 7cc1917 commit 3edcd2f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
8 changes: 1 addition & 7 deletions lib/internal/util/inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,6 @@ const {
} = require('internal/util');

const {
codes: {
ERR_INVALID_ARG_TYPE
},
isStackOverflowError
} = require('internal/errors');

Expand Down Expand Up @@ -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);
}

Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-util-format.js
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,7 @@ assert.strictEqual(
5,
'test',
Symbol(),
[],
].forEach((invalidOptions) => {
assert.throws(() => {
util.formatWithOptions(invalidOptions, { a: true });
Expand Down

0 comments on commit 3edcd2f

Please sign in to comment.