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 <[email protected]>
Reviewed-By: Mestery <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Zijian Liu <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
VoltrexKeyva authored and danielleadams committed Mar 4, 2022
1 parent b2bdddb commit 3f14458
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 3f14458

Please sign in to comment.