diff --git a/lib/internal/streams/operators.js b/lib/internal/streams/operators.js index 1cd4d7aa8951..5002bfb76abf 100644 --- a/lib/internal/streams/operators.js +++ b/lib/internal/streams/operators.js @@ -124,7 +124,7 @@ function map(fn, options) { PromisePrototypeThen(val, afterItemProcessed, onCatch); - queue.push(val); + queue[queue.length] = val; if (next) { next(); next = null; @@ -136,11 +136,11 @@ function map(fn, options) { }); } } - queue.push(kEof); + queue[queue.length] = kEof; } catch (err) { const val = PromiseReject(err); PromisePrototypeThen(val, afterItemProcessed, onCatch); - queue.push(val); + queue[queue.length] = val; } finally { done = true; if (next) { diff --git a/lib/internal/streams/pipeline.js b/lib/internal/streams/pipeline.js index 6937d4354340..b70e1443f0fa 100644 --- a/lib/internal/streams/pipeline.js +++ b/lib/internal/streams/pipeline.js @@ -270,10 +270,10 @@ function pipelineImpl(streams, callback, opts) { if (end) { const { destroy, cleanup } = destroyer(stream, reading, writing); - destroys.push(destroy); + destroys[destroys.length] = destroy; if (isReadable(stream) && isLastStream) { - lastStreamCleanup.push(cleanup); + lastStreamCleanup[lastStreamCleanup.length] = cleanup; } } @@ -289,9 +289,9 @@ function pipelineImpl(streams, callback, opts) { } stream.on('error', onError); if (isReadable(stream) && isLastStream) { - lastStreamCleanup.push(() => { + lastStreamCleanup[lastStreamCleanup.length] = () => { stream.removeListener('error', onError); - }); + }; } } @@ -367,9 +367,9 @@ function pipelineImpl(streams, callback, opts) { ret = pt; const { destroy, cleanup } = destroyer(ret, false, true); - destroys.push(destroy); + destroys[destroys.length] = destroy; if (isLastStream) { - lastStreamCleanup.push(cleanup); + lastStreamCleanup[lastStreamCleanup.length] = cleanup; } } } else if (isNodeStream(stream)) { @@ -377,7 +377,7 @@ function pipelineImpl(streams, callback, opts) { finishCount += 2; const cleanup = pipe(ret, stream, finish, finishOnlyHandleError, { end }); if (isReadable(stream) && isLastStream) { - lastStreamCleanup.push(cleanup); + lastStreamCleanup[lastStreamCleanup.length] = cleanup; } } else if (isTransformStream(ret) || isReadableStream(ret)) { const toRead = ret.readable || ret; diff --git a/lib/stream/consumers.js b/lib/stream/consumers.js index 09bd692bc17c..d61704f53276 100644 --- a/lib/stream/consumers.js +++ b/lib/stream/consumers.js @@ -51,7 +51,7 @@ const { async function blob(stream) { const chunks = []; for await (const chunk of stream) - chunks.push(chunk); + chunks[chunks.length] = chunk; return new Blob(chunks); }