Skip to content

Commit 14d7210

Browse files
committed
lib: simplify codedTypeError signature
Signed-off-by: Antoine du Hamel <[email protected]>
1 parent 48dce8b commit 14d7210

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

lib/internal/webidl.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ const {
1515
NumberIsNaN,
1616
NumberMAX_SAFE_INTEGER,
1717
NumberMIN_SAFE_INTEGER,
18-
ObjectAssign,
1918
ObjectPrototypeIsPrototypeOf,
2019
SafeSet,
2120
String,
@@ -31,7 +30,7 @@ const {
3130
ERR_INVALID_ARG_VALUE,
3231
},
3332
} = require('internal/errors');
34-
const { kEmptyObject } = require('internal/util');
33+
const { kEmptyObject, setOwnProperty } = require('internal/util');
3534
const {
3635
isArrayBuffer,
3736
isTypedArray,
@@ -220,10 +219,10 @@ converters.DOMString = function DOMString(V) {
220219

221220
converters['sequence<object>'] = createSequenceConverter(converters.object);
222221

223-
function codedTypeError(message, errorProperties = kEmptyObject) {
222+
function codedTypeError(message, code) {
224223
// eslint-disable-next-line no-restricted-syntax
225224
const err = new TypeError(message);
226-
ObjectAssign(err, errorProperties);
225+
setOwnProperty(err, 'code', code);
227226
return err;
228227
}
229228

@@ -233,7 +232,7 @@ function makeException(message, opts = kEmptyObject) {
233232
'' : (opts.context ?? 'Value') + ' ';
234233
return codedTypeError(
235234
`${prefix}${context}${message}`,
236-
{ code: opts.code || 'ERR_INVALID_ARG_TYPE' },
235+
opts.code || 'ERR_INVALID_ARG_TYPE',
237236
);
238237
}
239238

0 commit comments

Comments
 (0)