Skip to content

Commit

Permalink
buffer: don't predefine error
Browse files Browse the repository at this point in the history
PR-URL: #17021
Fixes: #16994
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
ah-yu authored and MylesBorins committed Dec 11, 2017
1 parent 16f181e commit 883281b
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -449,14 +449,12 @@ Buffer.isEncoding = function isEncoding(encoding) {
};
Buffer[kIsEncodingSymbol] = Buffer.isEncoding;

const kConcatErr = new errors.TypeError(
'ERR_INVALID_ARG_TYPE', 'list', ['Array', 'Buffer', 'Uint8Array']
);

Buffer.concat = function concat(list, length) {
var i;
if (!Array.isArray(list))
throw kConcatErr;
throw new errors.TypeError(
'ERR_INVALID_ARG_TYPE', 'list', ['Array', 'Buffer', 'Uint8Array']
);

if (list.length === 0)
return new FastBuffer();
Expand All @@ -474,7 +472,9 @@ Buffer.concat = function concat(list, length) {
for (i = 0; i < list.length; i++) {
var buf = list[i];
if (!isUint8Array(buf))
throw kConcatErr;
throw new errors.TypeError(
'ERR_INVALID_ARG_TYPE', 'list', ['Array', 'Buffer', 'Uint8Array']
);
_copy(buf, buffer, pos);
pos += buf.length;
}
Expand Down

0 comments on commit 883281b

Please sign in to comment.