From adf6d80cb75bb9945345b285482b20f17e75ffb4 Mon Sep 17 00:00:00 2001 From: Mohammed Keyvanzadeh Date: Fri, 4 Feb 2022 03:26:20 +0330 Subject: [PATCH] lib: refactor to use `validateObject()` validator Use the `validateObject()` validator in source maps where appropriate. --- 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 e6f7cdc08f3fd2..ec10dbfdf84389 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) &&