From 3f144585539841484d30ee7c78bf57cd17b9b5e7 Mon Sep 17 00:00:00 2001 From: Mohammed Keyvanzadeh Date: Sun, 6 Feb 2022 16:39:08 +0330 Subject: [PATCH] lib: refactor to use `validateObject()` validator Use the `validateObject()` validator in source maps where appropriate. PR-URL: https://github.com/nodejs/node/pull/41845 Reviewed-By: Antoine du Hamel Reviewed-By: Mestery Reviewed-By: Colin Ihrig Reviewed-By: Zijian Liu Reviewed-By: James M Snell --- lib/internal/source_map/source_map.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/internal/source_map/source_map.js b/lib/internal/source_map/source_map.js index e6f7cdc08f3fd22..ec10dbfdf84389d 100644 --- a/lib/internal/source_map/source_map.js +++ b/lib/internal/source_map/source_map.js @@ -75,9 +75,7 @@ const { StringPrototypeCharAt, } = primordials; -const { - ERR_INVALID_ARG_TYPE -} = require('internal/errors').codes; +const { validateObject } = require('internal/validators'); let base64Map; @@ -317,9 +315,7 @@ function decodeVLQ(stringCharIterator) { * @return {SourceMapV3} */ function cloneSourceMapV3(payload) { - if (typeof payload !== 'object') { - throw new ERR_INVALID_ARG_TYPE('payload', ['Object'], payload); - } + validateObject(payload, 'payload'); payload = { ...payload }; for (const key in payload) { if (ObjectPrototypeHasOwnProperty(payload, key) &&