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: Reverting change in let to fix regressions in buffer operations #5819

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
7 changes: 4 additions & 3 deletions lib/buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ function fromString(string, encoding) {
function fromArrayLike(obj) {
const length = obj.length;
const b = allocate(length);
for (let i = 0; i < length; i++)
for (var i = 0; i < length; i++)
b[i] = obj[i] & 255;
return b;
}
Expand Down Expand Up @@ -276,6 +276,7 @@ Buffer.isEncoding = function(encoding) {


Buffer.concat = function(list, length) {
var i;
if (!Array.isArray(list))
throw new TypeError('"list" argument must be an Array of Buffers');

Expand All @@ -284,15 +285,15 @@ Buffer.concat = function(list, length) {

if (length === undefined) {
length = 0;
for (let i = 0; i < list.length; i++)
for (i = 0; i < list.length; i++)
length += list[i].length;
} else {
length = length >>> 0;
}

var buffer = Buffer.allocUnsafe(length);
var pos = 0;
for (let i = 0; i < list.length; i++) {
for (i = 0; i < list.length; i++) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wondering why no var here. Looks like it was there previously 2ac47f8. At this point since its a jslint error all I can think of is that we have tightened up the lint rules ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this was to address a lint issue.

Really the var i in the for loop before should be declared outside of the if statement, so have added another commit to fix this,

var buf = list[i];
if (!Buffer.isBuffer(buf))
throw new TypeError('"list" argument must be an Array of Buffers');
Expand Down