From f6acf9a7b5b25c2818d8c37932c590845fc74bb0 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] stream: use for...of MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/30960 Reviewed-By: Matteo Collina Reviewed-By: Luigi Pinca Reviewed-By: Anna Henningsen Reviewed-By: Rich Trott Reviewed-By: Ruben Bridgewater Reviewed-By: Michaƫl Zasso Reviewed-By: James M Snell --- lib/_stream_duplex.js | 4 +--- lib/_stream_readable.js | 4 ++-- 2 files changed, 3 insertions(+), 5 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]; } diff --git a/lib/_stream_readable.js b/lib/_stream_readable.js index ff7d95554acd70..5fbf0e030a6862 100644 --- a/lib/_stream_readable.js +++ b/lib/_stream_readable.js @@ -1064,8 +1064,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