Skip to content

Commit ce49f90

Browse files
committed
stream: use for...of
PR-URL: #30960 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 6859fcf commit ce49f90

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
@@ -877,8 +877,8 @@ Readable.prototype.unpipe = function(dest) {
877877
state.pipes = [];
878878
state.flowing = false;
879879

880-
for (var i = 0; i < dests.length; i++)
881-
dests[i].emit('unpipe', this, { hasUnpiped: false });
880+
for (const dest of dests)
881+
dest.emit('unpipe', this, { hasUnpiped: false });
882882
return this;
883883
}
884884

@@ -1082,8 +1082,8 @@ Readable.prototype.wrap = function(stream) {
10821082
}
10831083

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

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

0 commit comments

Comments
 (0)