X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fselection-strategies%2Fworker-choice-strategies-context.ts;fp=src%2Fpools%2Fselection-strategies%2Fworker-choice-strategies-context.ts;h=185fed71287e668179e201d7ee79848463fd1d76;hb=63af54001cdb7be2f14d51be593a7f96c8c480b6;hp=d088015acc1ad9b62fd57a1221871e42210418bb;hpb=b1d9fd789d6642e6904dc33637e8e0761479dc60;p=poolifier.git diff --git a/src/pools/selection-strategies/worker-choice-strategies-context.ts b/src/pools/selection-strategies/worker-choice-strategies-context.ts index d088015a..185fed71 100644 --- a/src/pools/selection-strategies/worker-choice-strategies-context.ts +++ b/src/pools/selection-strategies/worker-choice-strategies-context.ts @@ -137,11 +137,10 @@ export class WorkerChoiceStrategiesContext< * @returns `true` if the update is successful, `false` otherwise. */ public update (workerNodeKey: number): boolean { - const res: boolean[] = [] - for (const workerChoiceStrategy of this.workerChoiceStrategies.values()) { - res.push(workerChoiceStrategy.update(workerNodeKey)) - } - return res.every(r => r) + return Array.from( + this.workerChoiceStrategies, + ([_, workerChoiceStrategy]) => workerChoiceStrategy.update(workerNodeKey) + ).every(r => r) } /** @@ -195,11 +194,10 @@ export class WorkerChoiceStrategiesContext< * @returns `true` if the removal is successful, `false` otherwise. */ public remove (workerNodeKey: number): boolean { - const res: boolean[] = [] - for (const workerChoiceStrategy of this.workerChoiceStrategies.values()) { - res.push(workerChoiceStrategy.remove(workerNodeKey)) - } - return res.every(r => r) + return Array.from( + this.workerChoiceStrategies, + ([_, workerChoiceStrategy]) => workerChoiceStrategy.remove(workerNodeKey) + ).every(r => r) } /**