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:
parent
3f568e0e2b
commit
90bc773fb8
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user