From 417120a3a3b345b8232af029d97e9e132965392d Mon Sep 17 00:00:00 2001 From: YoonSoo_Shin <89785501+MCprotein@users.noreply.github.com> Date: Mon, 12 Aug 2024 16:05:39 +0900 Subject: [PATCH] lib: replace spread operator with primordials function replaced the spread operator with ArrayPrototypeSlice to avoid reliance on user-mutable methods and enhance the safety of array iteration Refs: https://github.com/nodejs/node/blob/main/doc/contributing/primordials.md#unsafe-array-iteration PR-URL: https://github.com/nodejs/node/pull/54053 Refs: https://github.com/nodejs/node/blob/main/doc/contributing/primordials.md#unsafe-array-iteration Reviewed-By: Matteo Collina Reviewed-By: Yagiz Nizipli Reviewed-By: Raz Luvaton --- lib/internal/streams/compose.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/internal/streams/compose.js b/lib/internal/streams/compose.js index 1b04a0f70a1e62..276ae6276071f6 100644 --- a/lib/internal/streams/compose.js +++ b/lib/internal/streams/compose.js @@ -1,5 +1,9 @@ 'use strict'; +const { + ArrayPrototypeSlice, +} = primordials; + const { pipeline } = require('internal/streams/pipeline'); const Duplex = require('internal/streams/duplex'); const { destroyer } = require('internal/streams/destroy'); @@ -30,7 +34,7 @@ module.exports = function compose(...streams) { return Duplex.from(streams[0]); } - const orgStreams = [...streams]; + const orgStreams = ArrayPrototypeSlice(streams); if (typeof streams[0] === 'function') { streams[0] = Duplex.from(streams[0]);