Skip to content

Commit 883281b

Browse files
ah-yuMylesBorins
authored andcommitted
buffer: don't predefine error
PR-URL: #17021 Fixes: #16994 Reviewed-By: Evan Lucas <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anatoli Papirovski <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent 16f181e commit 883281b

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

lib/buffer.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -449,14 +449,12 @@ Buffer.isEncoding = function isEncoding(encoding) {
449449
};
450450
Buffer[kIsEncodingSymbol] = Buffer.isEncoding;
451451

452-
const kConcatErr = new errors.TypeError(
453-
'ERR_INVALID_ARG_TYPE', 'list', ['Array', 'Buffer', 'Uint8Array']
454-
);
455-
456452
Buffer.concat = function concat(list, length) {
457453
var i;
458454
if (!Array.isArray(list))
459-
throw kConcatErr;
455+
throw new errors.TypeError(
456+
'ERR_INVALID_ARG_TYPE', 'list', ['Array', 'Buffer', 'Uint8Array']
457+
);
460458

461459
if (list.length === 0)
462460
return new FastBuffer();
@@ -474,7 +472,9 @@ Buffer.concat = function concat(list, length) {
474472
for (i = 0; i < list.length; i++) {
475473
var buf = list[i];
476474
if (!isUint8Array(buf))
477-
throw kConcatErr;
475+
throw new errors.TypeError(
476+
'ERR_INVALID_ARG_TYPE', 'list', ['Array', 'Buffer', 'Uint8Array']
477+
);
478478
_copy(buf, buffer, pos);
479479
pos += buf.length;
480480
}

0 commit comments

Comments
 (0)