X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Futils.ts;h=8e84e9474c8a91d1adceb740e5c5ff21292faa02;hb=35e8f29cac8e1c1fecb8a3404107602d2d482f19;hp=20493767db87d80689a6cb067df3e22f72b759ce;hpb=00e1bdeb5c50b0eede8fe2f72d47bf8992e4aede;p=poolifier.git diff --git a/src/utils.ts b/src/utils.ts index 20493767..8e84e947 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -291,12 +291,12 @@ export const buildInternalWorkerChoiceStrategyOptions = ( opts?: InternalWorkerChoiceStrategyOptions ): InternalWorkerChoiceStrategyOptions => { opts = clone(opts ?? {}) - if (opts.weights == null) { + if (opts?.weights == null) { opts.weights = getDefaultWeights(poolMaxSize) } return { ...getDefaultInternalWorkerChoiceStrategyOptions( - poolMaxSize + Object.keys(opts?.weights ?? {}).length + poolMaxSize + Object.keys(opts.weights).length ), ...opts }