Skip to content

Commit

Permalink
stream: change stream to use index instead of for...of
Browse files Browse the repository at this point in the history
PR-URL: #54474
Refs: https://github.com/nodejs/node/blob/main/doc/contributing/primordials.md#unsafe-array-iteration
Reviewed-By: Daeyeon Jeong <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Raz Luvaton <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
  • Loading branch information
HBSPS authored and RafaelGSS committed Aug 30, 2024
1 parent b584356 commit fffc300
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ Stream.isReadable = utils.isReadable;
Stream.isWritable = utils.isWritable;

Stream.Readable = require('internal/streams/readable');
for (const key of ObjectKeys(streamReturningOperators)) {
const streamKeys = ObjectKeys(streamReturningOperators);
for (let i = 0; i < streamKeys.length; i++) {
const key = streamKeys[i];
const op = streamReturningOperators[key];
function fn(...args) {
if (new.target) {
Expand All @@ -79,7 +81,9 @@ for (const key of ObjectKeys(streamReturningOperators)) {
writable: true,
});
}
for (const key of ObjectKeys(promiseReturningOperators)) {
const promiseKeys = ObjectKeys(promiseReturningOperators);
for (let i = 0; i < promiseKeys.length; i++) {
const key = promiseKeys[i];
const op = promiseReturningOperators[key];
function fn(...args) {
if (new.target) {
Expand Down

0 comments on commit fffc300

Please sign in to comment.