From 15eff383aa7e52fe418b84ded074740befd899a1 Mon Sep 17 00:00:00 2001 From: Ayoub Mabrouk Date: Mon, 29 Dec 2025 19:42:42 +0100 Subject: [PATCH] stream: replace native methods with primordials Replace native methods with primordials. --- lib/internal/streams/writable.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/internal/streams/writable.js b/lib/internal/streams/writable.js index 1081db9ffcf661..cb45d7f7a9cab2 100644 --- a/lib/internal/streams/writable.js +++ b/lib/internal/streams/writable.js @@ -26,7 +26,9 @@ 'use strict'; const { + ArrayPrototypePush, ArrayPrototypeSlice, + ArrayPrototypeSplice, Error, FunctionPrototypeSymbolHasInstance, ObjectDefineProperties, @@ -554,7 +556,7 @@ function writeOrBuffer(stream, state, chunk, encoding, callback) { state[kBufferedValue] = []; } - state[kBufferedValue].push({ chunk, encoding, callback }); + ArrayPrototypePush(state[kBufferedValue], { chunk, encoding, callback }); if ((state[kState] & kAllBuffers) !== 0 && encoding !== 'buffer') { state[kState] &= ~kAllBuffers; } @@ -784,7 +786,7 @@ function clearBuffer(stream, state) { if (i === buffered.length) { resetBuffer(state); } else if (i > 256) { - buffered.splice(0, i); + ArrayPrototypeSplice(buffered, 0, i); state.bufferedIndex = 0; } else { state.bufferedIndex = i; @@ -858,7 +860,7 @@ Writable.prototype.end = function(chunk, encoding, cb) { } else { state[kState] |= kOnFinished; state[kOnFinishedValue] ??= []; - state[kOnFinishedValue].push(cb); + ArrayPrototypePush(state[kOnFinishedValue], cb); } }