From a10278fee9af1ed7d166292f508d7ba81d7b5c58 Mon Sep 17 00:00:00 2001 From: telenord Date: Wed, 6 Nov 2019 13:53:39 +0300 Subject: [PATCH] http: http_outgoing rename var to let and const --- lib/_http_outgoing.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/_http_outgoing.js b/lib/_http_outgoing.js index 36d3054eab0663..c1f277da3fff57 100644 --- a/lib/_http_outgoing.js +++ b/lib/_http_outgoing.js @@ -168,7 +168,7 @@ ObjectDefineProperty(OutgoingMessage.prototype, '_headers', { const keys = ObjectKeys(val); // Retain for(;;) loop for performance reasons // Refs: https://github.com/nodejs/node/pull/30958 - for (var i = 0; i < keys.length; ++i) { + for (let i = 0; i < keys.length; ++i) { const name = keys[i]; headers[name.toLowerCase()] = [name, val[name]]; } @@ -193,7 +193,7 @@ ObjectDefineProperty(OutgoingMessage.prototype, '_headerNames', { const keys = ObjectKeys(headers); // Retain for(;;) loop for performance reasons // Refs: https://github.com/nodejs/node/pull/30958 - for (var i = 0; i < keys.length; ++i) { + for (let i = 0; i < keys.length; ++i) { const key = keys[i]; const val = headers[key][0]; out[key] = val; @@ -210,7 +210,7 @@ ObjectDefineProperty(OutgoingMessage.prototype, '_headerNames', { const keys = ObjectKeys(val); // Retain for(;;) loop for performance reasons // Refs: https://github.com/nodejs/node/pull/30958 - for (var i = 0; i < keys.length; ++i) { + for (let i = 0; i < keys.length; ++i) { const header = headers[keys[i]]; if (header) header[0] = val[keys[i]]; @@ -232,7 +232,7 @@ OutgoingMessage.prototype._renderHeaders = function _renderHeaders() { const keys = ObjectKeys(headersMap); // Retain for(;;) loop for performance reasons // Refs: https://github.com/nodejs/node/pull/30958 - for (var i = 0, l = keys.length; i < l; i++) { + for (let i = 0, l = keys.length; i < l; i++) { const key = keys[i]; headers[headersMap[key][0]] = headersMap[key][1]; } @@ -297,7 +297,7 @@ OutgoingMessage.prototype._send = function _send(data, encoding, callback) { (encoding === 'utf8' || encoding === 'latin1' || !encoding)) { data = this._header + data; } else { - var header = this._header; + const header = this._header; if (this.outputData.length === 0) { this.outputData = [{ data: header, @@ -468,7 +468,7 @@ function processHeader(self, state, key, value, validate) { if (value.length < 2 || !isCookieField(key)) { // Retain for(;;) loop for performance reasons // Refs: https://github.com/nodejs/node/pull/30958 - for (var i = 0; i < value.length; i++) + for (let i = 0; i < value.length; i++) storeHeader(self, state, key, value[i], validate); return; } @@ -571,7 +571,7 @@ OutgoingMessage.prototype.getHeaders = function getHeaders() { const keys = ObjectKeys(headers); // Retain for(;;) loop for performance reasons // Refs: https://github.com/nodejs/node/pull/30958 - for (var i = 0; i < keys.length; ++i) { + for (let i = 0; i < keys.length; ++i) { const key = keys[i]; const val = headers[key][1]; ret[key] = val; @@ -676,8 +676,9 @@ function write_(msg, chunk, encoding, callback, fromEnd) { process.nextTick(connectionCorkNT, msg.socket); } - var len, ret; + let ret; if (msg.chunkedEncoding && chunk.length !== 0) { + let len; if (typeof chunk === 'string') len = Buffer.byteLength(chunk, encoding); else @@ -711,11 +712,11 @@ OutgoingMessage.prototype.addTrailers = function addTrailers(headers) { this._trailer = ''; const keys = ObjectKeys(headers); const isArray = ArrayIsArray(headers); - var field, value; // Retain for(;;) loop for performance reasons // Refs: https://github.com/nodejs/node/pull/30958 - for (var i = 0, l = keys.length; i < l; i++) { - var key = keys[i]; + for (let i = 0, l = keys.length; i < l; i++) { + let field, value; + const key = keys[i]; if (isArray) { field = headers[key][0]; value = headers[key][1]; @@ -839,11 +840,10 @@ OutgoingMessage.prototype._finish = function _finish() { // to attempt to flush any pending messages out to the socket. OutgoingMessage.prototype._flush = function _flush() { const socket = this.socket; - var ret; if (socket && socket.writable) { // There might be remaining data in this.output; write it out - ret = this._flushOutput(socket); + const ret = this._flushOutput(socket); if (this.finished) { // This is a queue to the server or client to bring in the next this. @@ -870,7 +870,7 @@ OutgoingMessage.prototype._flushOutput = function _flushOutput(socket) { let ret; // Retain for(;;) loop for performance reasons // Refs: https://github.com/nodejs/node/pull/30958 - for (var i = 0; i < outputLength; i++) { + for (let i = 0; i < outputLength; i++) { const { data, encoding, callback } = outputData[i]; ret = socket.write(data, encoding, callback); }