From 2cc0cfb2137c25dafd30a6958911c6c934dffd97 Mon Sep 17 00:00:00 2001 From: gengjiawen Date: Sun, 10 Mar 2019 13:00:07 +0800 Subject: [PATCH 1/3] http: delay ret declaration in method _flushOutput --- lib/_http_outgoing.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/_http_outgoing.js b/lib/_http_outgoing.js index 60ed6779c47979..ebc40d0961f105 100644 --- a/lib/_http_outgoing.js +++ b/lib/_http_outgoing.js @@ -792,13 +792,13 @@ OutgoingMessage.prototype._flush = function _flush() { }; OutgoingMessage.prototype._flushOutput = function _flushOutput(socket) { - var ret; - var outputLength = this.outputData.length; + const outputLength = this.outputData.length; if (outputLength <= 0) - return ret; + return undefined; - var outputData = this.outputData; + const outputData = this.outputData; socket.cork(); + let ret; for (var i = 0; i < outputLength; i++) { const { data, encoding, callback } = outputData[i]; ret = socket.write(data, encoding, callback); From 4bd26350355bb8e8e78f515112afed07d41951eb Mon Sep 17 00:00:00 2001 From: gengjiawen Date: Sun, 10 Mar 2019 13:01:25 +0800 Subject: [PATCH 2/3] repl: remove redundant initialization --- lib/repl.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/repl.js b/lib/repl.js index a641843d2c7fa3..f86ec72a8a0de3 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -1030,8 +1030,7 @@ function complete(line, callback) { // REPL commands (e.g. ".break"). var filter; - var match = null; - match = line.match(/^\s*\.(\w*)$/); + let match = line.match(/^\s*\.(\w*)$/); if (match) { completionGroups.push(Object.keys(this.commands)); completeOn = match[1]; From d768c5c6f2d50968b603a8996d1c3b55f3e06b54 Mon Sep 17 00:00:00 2001 From: gengjiawen Date: Sun, 10 Mar 2019 13:12:25 +0800 Subject: [PATCH 3/3] lib: make lowerProto scope more clear --- lib/url.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/url.js b/lib/url.js index 391d6c2723d99d..b41000332a453b 100644 --- a/lib/url.js +++ b/lib/url.js @@ -250,10 +250,11 @@ Url.prototype.parse = function parse(url, parseQueryString, slashesDenoteHost) { } } - var proto = protocolPattern.exec(rest); + let proto = protocolPattern.exec(rest); + let lowerProto; if (proto) { proto = proto[0]; - var lowerProto = proto.toLowerCase(); + lowerProto = proto.toLowerCase(); this.protocol = lowerProto; rest = rest.slice(proto.length); }