Skip to content
Permalink
Browse files

stream: use for...of

PR-URL: #30960
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
trivikr committed Dec 14, 2019
1 parent 6859fcf commit ce49f90e14212cd900aba69bac76a8af288d2b58
Showing with 5 additions and 7 deletions.
  1. +1 −3 lib/_stream_duplex.js
  2. +4 −4 lib/_stream_readable.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];
}
@@ -877,8 +877,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 of dests)
dest.emit('unpipe', this, { hasUnpiped: false });
return this;
}

@@ -1082,8 +1082,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

0 comments on commit ce49f90

Please sign in to comment.
You can’t perform that action at this time.