From ef165064634e1da6ba8303b08000ba9f079271a5 Mon Sep 17 00:00:00 2001 From: Trivikram Kamat <16024985+trivikr@users.noreply.github.com> Date: Sat, 14 Dec 2019 10:14:48 -0500 Subject: [PATCH 1/3] stream: for...of in _stream_duplex.js --- lib/_stream_duplex.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/_stream_duplex.js b/lib/_stream_duplex.js index 572e6da94d8a6a..af2522313f80a2 100644 --- a/lib/_stream_duplex.js +++ b/lib/_stream_duplex.js @@ -42,9 +42,7 @@ ObjectSetPrototypeOf(Duplex, Readable); { // Allow the keys array to be GC'ed. - const keys = ObjectKeys(Writable.prototype); - for (let v = 0; v < keys.length; v++) { - const method = keys[v]; + for (const method of ObjectKeys(Writable.prototype)) { if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method]; } From cd973facf0a8a3f77dd3373a60ee00031f8cc87d Mon Sep 17 00:00:00 2001 From: Trivikram Kamat <16024985+trivikr@users.noreply.github.com> Date: Sat, 14 Dec 2019 10:16:47 -0500 Subject: [PATCH 2/3] stream: for...of in _stream_readable.js --- lib/_stream_readable.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/_stream_readable.js b/lib/_stream_readable.js index 6226bbf5eb4063..6bc70d5f8295ab 100644 --- a/lib/_stream_readable.js +++ b/lib/_stream_readable.js @@ -874,8 +874,8 @@ Readable.prototype.unpipe = function(dest) { state.pipes = []; state.flowing = false; - for (var i = 0; i < dests.length; i++) - dests[i].emit('unpipe', this, { hasUnpiped: false }); + for (const dest in dests) + dest.emit('unpipe', this, { hasUnpiped: false }); return this; } @@ -1079,8 +1079,8 @@ Readable.prototype.wrap = function(stream) { } // Proxy certain important events. - for (var n = 0; n < kProxyEvents.length; n++) { - stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n])); + for (const kProxyEvent of kProxyEvents) { + stream.on(kProxyEvent, this.emit.bind(this, kProxyEvent)); } // When we try to consume some more bytes, simply unpause the From 80731ed7ca9ff4c112d99bc3ecec3a5313869c97 Mon Sep 17 00:00:00 2001 From: Trivikram Kamat <16024985+trivikr@users.noreply.github.com> Date: Sat, 14 Dec 2019 10:50:53 -0500 Subject: [PATCH 3/3] f typo for...in to for...of --- lib/_stream_readable.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/_stream_readable.js b/lib/_stream_readable.js index 6bc70d5f8295ab..d8cb99c022f49d 100644 --- a/lib/_stream_readable.js +++ b/lib/_stream_readable.js @@ -874,7 +874,7 @@ Readable.prototype.unpipe = function(dest) { state.pipes = []; state.flowing = false; - for (const dest in dests) + for (const dest of dests) dest.emit('unpipe', this, { hasUnpiped: false }); return this; }