Skip to content

Commit d6515f2

Browse files
author
yoonsooshin
committed
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
1 parent b32732b commit d6515f2

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/internal/streams/compose.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ const {
2020
},
2121
} = require('internal/errors');
2222
const eos = require('internal/streams/end-of-stream');
23+
const {
24+
ArrayPrototypeSlice
25+
} = primordials;
2326

2427
module.exports = function compose(...streams) {
2528
if (streams.length === 0) {
@@ -30,7 +33,7 @@ module.exports = function compose(...streams) {
3033
return Duplex.from(streams[0]);
3134
}
3235

33-
const orgStreams = [...streams];
36+
const orgStreams = ArrayPrototypeSlice(streams);
3437

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

0 commit comments

Comments
 (0)