Skip to content

Commit 8f845eb

Browse files
sanjaiyan-devRafaelGSS
authored andcommitted
lib: move function declaration outside of loop
PR-URL: #51242 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]>
1 parent 6648a5c commit 8f845eb

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/internal/per_context/primordials.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -541,11 +541,14 @@ primordials.SafePromiseAllReturnVoid = (promises, mapFn) =>
541541
new Promise((resolve, reject) => {
542542
let pendingPromises = promises.length;
543543
if (pendingPromises === 0) resolve();
544+
const onFulfilled = () => {
545+
if (--pendingPromises === 0) {
546+
resolve();
547+
}
548+
};
544549
for (let i = 0; i < promises.length; i++) {
545550
const promise = mapFn != null ? mapFn(promises[i], i) : promises[i];
546-
PromisePrototypeThen(PromiseResolve(promise), () => {
547-
if (--pendingPromises === 0) resolve();
548-
}, reject);
551+
PromisePrototypeThen(PromiseResolve(promise), onFulfilled, reject);
549552
}
550553
});
551554

0 commit comments

Comments
 (0)