refactor: remove unneeded type casting
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Tue, 19 Dec 2023 22:50:33 +0000 (23:50 +0100)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Tue, 19 Dec 2023 22:50:33 +0000 (23:50 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
src/pools/selection-strategies/abstract-worker-choice-strategy.ts
src/pools/selection-strategies/worker-choice-strategy-context.ts

index 7324c511cca18f76b89c254f1deb777ae06c2dbe..b15ade84023167c4a507b1bacb32a98857fe731d 100644 (file)
@@ -114,8 +114,7 @@ export abstract class AbstractWorkerChoiceStrategy<
   public setOptions (opts: InternalWorkerChoiceStrategyOptions): void {
     this.opts = {
       ...getDefaultInternalWorkerChoiceStrategyOptions(
-        this.pool.info.maxSize +
-          Object.keys((opts?.weights as Record<number, number>) ?? {}).length
+        this.pool.info.maxSize + Object.keys(opts?.weights ?? {}).length
       ),
       ...opts
     }
index cf1b005169d8fbaa04fb074adb4f3f2966cbe335..6f15daa0645174b4ce55008dbd46057a40f9c927 100644 (file)
@@ -48,9 +48,7 @@ export class WorkerChoiceStrategyContext<
   ) {
     this.opts = {
       ...getDefaultInternalWorkerChoiceStrategyOptions(
-        pool.info.maxSize +
-          Object.keys((this.opts?.weights as Record<number, number>) ?? {})
-            .length
+        pool.info.maxSize + Object.keys(this.opts?.weights ?? {}).length
       ),
       ...this.opts
     }
@@ -237,8 +235,7 @@ export class WorkerChoiceStrategyContext<
   ): void {
     this.opts = {
       ...getDefaultInternalWorkerChoiceStrategyOptions(
-        pool.info.maxSize +
-          Object.keys((opts?.weights as Record<number, number>) ?? {}).length
+        pool.info.maxSize + Object.keys(opts?.weights ?? {}).length
       ),
       ...opts
     }