Skip to content

Commit ad254f3

Browse files
committed
stream: replace native methods with primordials
Replace native methods with primordials.
1 parent 879b95e commit ad254f3

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

lib/internal/streams/pipeline.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55

66
const {
77
ArrayIsArray,
8+
ArrayPrototypePop,
9+
ArrayPrototypePush,
10+
ArrayPrototypeShift,
811
Promise,
912
SymbolAsyncIterator,
1013
SymbolDispose,
@@ -73,7 +76,7 @@ function popCallback(streams) {
7376
// a single stream. Therefore optimize for the average case instead of
7477
// checking for length === 0 as well.
7578
validateFunction(streams[streams.length - 1], 'streams[stream.length - 1]');
76-
return streams.pop();
79+
return ArrayPrototypePop(streams);
7780
}
7881

7982
function makeAsyncIterable(val) {
@@ -236,7 +239,7 @@ function pipelineImpl(streams, callback, opts) {
236239
}
237240

238241
while (destroys.length) {
239-
destroys.shift()(error);
242+
ArrayPrototypeShift(destroys)(error);
240243
}
241244

242245
disposable?.[SymbolDispose]();
@@ -266,10 +269,10 @@ function pipelineImpl(streams, callback, opts) {
266269

267270
if (end) {
268271
const { destroy, cleanup } = destroyer(stream, reading, writing);
269-
destroys.push(destroy);
272+
ArrayPrototypePush(destroys, destroy);
270273

271274
if (isReadable(stream) && isLastStream) {
272-
lastStreamCleanup.push(cleanup);
275+
ArrayPrototypePush(lastStreamCleanup, cleanup);
273276
}
274277
}
275278

@@ -285,7 +288,7 @@ function pipelineImpl(streams, callback, opts) {
285288
}
286289
stream.on('error', onError);
287290
if (isReadable(stream) && isLastStream) {
288-
lastStreamCleanup.push(() => {
291+
ArrayPrototypePush(lastStreamCleanup, () => {
289292
stream.removeListener('error', onError);
290293
});
291294
}
@@ -363,17 +366,17 @@ function pipelineImpl(streams, callback, opts) {
363366
ret = pt;
364367

365368
const { destroy, cleanup } = destroyer(ret, false, true);
366-
destroys.push(destroy);
369+
ArrayPrototypePush(destroys, destroy);
367370
if (isLastStream) {
368-
lastStreamCleanup.push(cleanup);
371+
ArrayPrototypePush(lastStreamCleanup, cleanup);
369372
}
370373
}
371374
} else if (isNodeStream(stream)) {
372375
if (isReadableNodeStream(ret)) {
373376
finishCount += 2;
374377
const cleanup = pipe(ret, stream, finish, finishOnlyHandleError, { end });
375378
if (isReadable(stream) && isLastStream) {
376-
lastStreamCleanup.push(cleanup);
379+
ArrayPrototypePush(lastStreamCleanup, cleanup);
377380
}
378381
} else if (isTransformStream(ret) || isReadableStream(ret)) {
379382
const toRead = ret.readable || ret;

0 commit comments

Comments
 (0)