Skip to content

Commit efb24b6

Browse files
anonrigaduh95
authored andcommitted
fs: refactor rimraf to avoid using primordials
PR-URL: #54834 Reviewed-By: LiviaMedeiros <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent 936d76d commit efb24b6

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lib/internal/fs/rimraf.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
'use strict';
88

99
const {
10-
ArrayPrototypeForEach,
1110
Promise,
1211
SafeSet,
1312
} = primordials;
@@ -139,8 +138,10 @@ function _rmchildren(path, options, callback) {
139138

140139
let done = false;
141140

142-
ArrayPrototypeForEach(files, (child) => {
143-
const childPath = Buffer.concat([pathBuf, separator, child]);
141+
const childPathPrefix = Buffer.concat([pathBuf, separator]);
142+
143+
for (let i = 0; i < files.length; i++) {
144+
const childPath = Buffer.concat([childPathPrefix, files[i]]);
144145

145146
rimraf(childPath, options, (err) => {
146147
if (done)
@@ -155,7 +156,7 @@ function _rmchildren(path, options, callback) {
155156
if (numFiles === 0)
156157
rmdir(path, callback);
157158
});
158-
});
159+
}
159160
});
160161
}
161162

0 commit comments

Comments
 (0)