Skip to content

Commit 5ca29d8

Browse files
trivikrMylesBorins
authored andcommitted
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>
1 parent d8ce9a0 commit 5ca29d8

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

lib/_stream_duplex.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@ ObjectSetPrototypeOf(Duplex, Readable);
4242

4343
{
4444
// Allow the keys array to be GC'ed.
45-
const keys = ObjectKeys(Writable.prototype);
46-
for (let v = 0; v < keys.length; v++) {
47-
const method = keys[v];
45+
for (const method of ObjectKeys(Writable.prototype)) {
4846
if (!Duplex.prototype[method])
4947
Duplex.prototype[method] = Writable.prototype[method];
5048
}

lib/_stream_readable.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -874,8 +874,8 @@ Readable.prototype.unpipe = function(dest) {
874874
state.pipes = [];
875875
state.flowing = false;
876876

877-
for (var i = 0; i < dests.length; i++)
878-
dests[i].emit('unpipe', this, { hasUnpiped: false });
877+
for (const dest of dests)
878+
dest.emit('unpipe', this, { hasUnpiped: false });
879879
return this;
880880
}
881881

@@ -1079,8 +1079,8 @@ Readable.prototype.wrap = function(stream) {
10791079
}
10801080

10811081
// Proxy certain important events.
1082-
for (var n = 0; n < kProxyEvents.length; n++) {
1083-
stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));
1082+
for (const kProxyEvent of kProxyEvents) {
1083+
stream.on(kProxyEvent, this.emit.bind(this, kProxyEvent));
10841084
}
10851085

10861086
// When we try to consume some more bytes, simply unpause the

0 commit comments

Comments
 (0)