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 targos committed Oct 2, 2024
1 parent d53e6cf commit 0c32918
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 0c32918

Please sign in to comment.