Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

buffer: don't predefine error #17021

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions lib/buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -447,14 +447,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 @@ -472,7 +470,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