Skip to content

Commit 6244070

Browse files
ah-yuaddaleax
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 66e2751 commit 6244070

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

lib/buffer.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -447,14 +447,12 @@ Buffer.isEncoding = function isEncoding(encoding) {
447447
};
448448
Buffer[kIsEncodingSymbol] = Buffer.isEncoding;
449449

450-
const kConcatErr = new errors.TypeError(
451-
'ERR_INVALID_ARG_TYPE', 'list', ['Array', 'Buffer', 'Uint8Array']
452-
);
453-
454450
Buffer.concat = function concat(list, length) {
455451
var i;
456452
if (!Array.isArray(list))
457-
throw kConcatErr;
453+
throw new errors.TypeError(
454+
'ERR_INVALID_ARG_TYPE', 'list', ['Array', 'Buffer', 'Uint8Array']
455+
);
458456

459457
if (list.length === 0)
460458
return new FastBuffer();
@@ -472,7 +470,9 @@ Buffer.concat = function concat(list, length) {
472470
for (i = 0; i < list.length; i++) {
473471
var buf = list[i];
474472
if (!isUint8Array(buf))
475-
throw kConcatErr;
473+
throw new errors.TypeError(
474+
'ERR_INVALID_ARG_TYPE', 'list', ['Array', 'Buffer', 'Uint8Array']
475+
);
476476
_copy(buf, buffer, pos);
477477
pos += buf.length;
478478
}

0 commit comments

Comments
 (0)