From f32aec8a6d3c20d9e38dc21e588090e9e133d750 Mon Sep 17 00:00:00 2001 From: Kohei Ueno Date: Wed, 13 Jul 2022 14:41:03 +0900 Subject: [PATCH] util: refactor to use validateObject PR-URL: https://github.com/nodejs/node/pull/43769 Reviewed-By: Colin Ihrig Reviewed-By: Darshan Sen Reviewed-By: Luigi Pinca Reviewed-By: Antoine du Hamel Reviewed-By: Mohammed Keyvanzadeh --- lib/internal/util/inspect.js | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js index 0ff86d92970ca5..fc52ba514e771b 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', { allowArray: true }); return formatWithOptionsInternal(inspectOptions, args); }