util: refactor to use validateObject

PR-URL: https://github.com/nodejs/node/pull/43769
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
This commit is contained in:
Kohei Ueno 2022-07-13 14:41:03 +09:00 committed by GitHub
parent 3f568e0e2b
commit 90bc773fb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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', { allowArray: true });
return formatWithOptionsInternal(inspectOptions, args);
}