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: change var to let #30292

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 @@ -317,7 +317,7 @@ Buffer.from = function from(value, encodingOrOffset, length) {
// Refs: https://esdiscuss.org/topic/isconstructor#content-11
const of = (...items) => {
const newObj = createUnsafeBuffer(items.length);
for (var k = 0; k < items.length; k++)
for (let k = 0; k < items.length; k++)
newObj[k] = items[k];
return newObj;
};
Expand Down Expand Up @@ -433,7 +433,7 @@ function fromString(string, encoding) {
function fromArrayLike(obj) {
const length = obj.length;
const b = allocate(length);
for (var i = 0; i < length; i++)
for (let i = 0; i < length; i++)
b[i] = obj[i];
return b;
}
Expand Down Expand Up @@ -1044,7 +1044,7 @@ Buffer.prototype.write = function write(string, offset, length, encoding) {
Buffer.prototype.toJSON = function toJSON() {
if (this.length > 0) {
const data = new Array(this.length);
for (var i = 0; i < this.length; ++i)
for (let i = 0; i < this.length; ++i)
data[i] = this[i];
return { type: 'Buffer', data };
}
Expand Down Expand Up @@ -1090,7 +1090,7 @@ Buffer.prototype.swap16 = function swap16() {
if (len % 2 !== 0)
throw new ERR_INVALID_BUFFER_SIZE('16-bits');
if (len < 128) {
for (var i = 0; i < len; i += 2)
for (let i = 0; i < len; i += 2)
swap(this, i, i + 1);
return this;
}
Expand All @@ -1105,7 +1105,7 @@ Buffer.prototype.swap32 = function swap32() {
if (len % 4 !== 0)
throw new ERR_INVALID_BUFFER_SIZE('32-bits');
if (len < 192) {
for (var i = 0; i < len; i += 4) {
for (let i = 0; i < len; i += 4) {
swap(this, i, i + 3);
swap(this, i + 1, i + 2);
}
Expand All @@ -1122,7 +1122,7 @@ Buffer.prototype.swap64 = function swap64() {
if (len % 8 !== 0)
throw new ERR_INVALID_BUFFER_SIZE('64-bits');
if (len < 192) {
for (var i = 0; i < len; i += 8) {
for (let i = 0; i < len; i += 8) {
swap(this, i, i + 7);
swap(this, i + 1, i + 6);
swap(this, i + 2, i + 5);
Expand Down