lib: refactor to use let

move variable into each for loop

PR-URL: https://github.com/nodejs/node/pull/40364
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Zijian Liu <lxxyxzj@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This commit is contained in:
gdccwxx 2021-10-07 20:42:57 +08:00 committed by Node.js GitHub Bot
parent eafdeab97b
commit ac4f5e2437
1 changed files with 3 additions and 5 deletions

View File

@ -61,8 +61,6 @@ function validateHandshake(requestKey, responseKey) {
}
function encodeFrameHybi17(payload) {
var i;
const dataLength = payload.length;
let singleByteLength;
@ -71,7 +69,7 @@ function encodeFrameHybi17(payload) {
singleByteLength = kEightBytePayloadLengthField;
additionalLength = Buffer.alloc(8);
let remaining = dataLength;
for (i = 0; i < 8; ++i) {
for (let i = 0; i < 8; ++i) {
additionalLength[7 - i] = remaining & 0xFF;
remaining >>= 8;
}
@ -92,7 +90,7 @@ function encodeFrameHybi17(payload) {
const mask = Buffer.alloc(4);
const masked = Buffer.alloc(dataLength);
for (i = 0; i < dataLength; ++i) {
for (let i = 0; i < dataLength; ++i) {
masked[i] = payload[i] ^ mask[i % kMaskingKeyWidthInBytes];
}
@ -147,7 +145,7 @@ function decodeFrameHybi17(data) {
case kEightBytePayloadLengthField:
payloadOffset += 8;
payloadLength = 0;
for (var i = 0; i < 8; ++i) {
for (let i = 0; i < 8; ++i) {
payloadLength <<= 8;
payloadLength |= data[2 + i];
}