Skip to content

Commit

Permalink
stream: use for...of
Browse files Browse the repository at this point in the history
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 authored and MylesBorins committed Dec 17, 2019
1 parent d8ce9a0 commit 5ca29d8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
4 changes: 1 addition & 3 deletions lib/_stream_duplex.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down
8 changes: 4 additions & 4 deletions lib/_stream_readable.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 of dests)
dest.emit('unpipe', this, { hasUnpiped: false });
return this;
}

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5ca29d8

Please sign in to comment.