mirror of
https://github.com/nodejs/node.git
synced 2026-11-25 23:01:06 -05:00
lib: move function declaration outside of loop
PR-URL: https://github.com/nodejs/node/pull/51242 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io>
This commit is contained in:
1 parent
eef64b782e
commit
7b83ef749e
1 file changed
+6
-3
@@ -540,11 +540,14 @@ primordials.SafePromiseAllReturnVoid = (promises, mapFn) =>
|
||||
new Promise((resolve, reject) => {
|
||||
let pendingPromises = promises.length;
|
||||
if (pendingPromises === 0) resolve();
|
||||
const onFulfilled = () => {
|
||||
if (--pendingPromises === 0) {
|
||||
resolve();
|
||||
}
|
||||
};
|
||||
for (let i = 0; i < promises.length; i++) {
|
||||
const promise = mapFn != null ? mapFn(promises[i], i) : promises[i];
|
||||
PromisePrototypeThen(PromiseResolve(promise), () => {
|
||||
if (--pendingPromises === 0) resolve();
|
||||
}, reject);
|
||||
PromisePrototypeThen(PromiseResolve(promise), onFulfilled, reject);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user