Skip to content

Commit

Permalink
lib: refactor to use validateObject() validator
Browse files Browse the repository at this point in the history
Use the `validateObject()` validator in source maps where appropriate.

PR-URL: nodejs#41845
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Mestery <mestery@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Zijian Liu <lxxyxzj@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
VoltrexKeyva authored and danielleadams committed Mar 4, 2022
1 parent fc41c2f commit 2647931
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions lib/internal/source_map/source_map.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,7 @@ const {
StringPrototypeCharAt,
} = primordials;

const {
ERR_INVALID_ARG_TYPE
} = require('internal/errors').codes;
const { validateObject } = require('internal/validators');

let base64Map;

Expand Down Expand Up @@ -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) &&
Expand Down

0 comments on commit 2647931

Please sign in to comment.