Skip to content

Commit

Permalink
worker: refactor to avoid unsafe array iteration
Browse files Browse the repository at this point in the history
PR-URL: #37346
Reviewed-By: Darshan Sen <[email protected]>
Reviewed-By: Harshitha K P <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
aduh95 authored and danielleadams committed Feb 16, 2021
1 parent 6d53e79 commit 05a16e7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/internal/main/worker_thread.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

const {
ArrayPrototypeConcat,
ArrayPrototypeForEach,
ArrayPrototypeSplice,
ObjectDefineProperty,
PromisePrototypeCatch,
Expand Down Expand Up @@ -178,8 +179,9 @@ port.on('message', (message) => {
}
} else if (message.type === STDIO_PAYLOAD) {
const { stream, chunks } = message;
for (const { chunk, encoding } of chunks)
ArrayPrototypeForEach(chunks, ({ chunk, encoding }) => {
process[stream].push(chunk, encoding);
});
} else {
assert(
message.type === STDIO_WANTS_MORE_DATA,
Expand Down

0 comments on commit 05a16e7

Please sign in to comment.