refactor: cleanup default arguments handling
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Wed, 20 Dec 2023 23:04:01 +0000 (00:04 +0100)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Wed, 20 Dec 2023 23:04:01 +0000 (00:04 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
src/utils.ts

index 8e84e9474c8a91d1adceb740e5c5ff21292faa02..3226e7eb3499af2fe2b1b6000962c83e14f10992 100644 (file)
@@ -304,8 +304,9 @@ export const buildInternalWorkerChoiceStrategyOptions = (
 
 const getDefaultWeights = (
   poolMaxSize: number,
-  defaultWorkerWeight: number = getDefaultWorkerWeight()
+  defaultWorkerWeight?: number
 ): Record<number, number> => {
+  defaultWorkerWeight = defaultWorkerWeight ?? getDefaultWorkerWeight()
   const weights: Record<number, number> = {}
   for (let workerNodeKey = 0; workerNodeKey < poolMaxSize; workerNodeKey++) {
     weights[workerNodeKey] = defaultWorkerWeight