Skip to content

Commit d7f3730

Browse files
authored
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: #54053 Refs: https://github.com/nodejs/node/blob/main/doc/contributing/primordials.md#unsafe-array-iteration Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Raz Luvaton <[email protected]>
1 parent 2a5b86b commit d7f3730

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/internal/streams/compose.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
'use strict';
22

3+
const {
4+
ArrayPrototypeSlice,
5+
} = primordials;
6+
37
const { pipeline } = require('internal/streams/pipeline');
48
const Duplex = require('internal/streams/duplex');
59
const { destroyer } = require('internal/streams/destroy');
@@ -30,7 +34,7 @@ module.exports = function compose(...streams) {
3034
return Duplex.from(streams[0]);
3135
}
3236

33-
const orgStreams = [...streams];
37+
const orgStreams = ArrayPrototypeSlice(streams);
3438

3539
if (typeof streams[0] === 'function') {
3640
streams[0] = Duplex.from(streams[0]);

0 commit comments

Comments
 (0)