From: Jérôme Benoit Date: Thu, 22 Apr 2021 20:42:05 +0000 (+0200) Subject: WorkerFactory.ts: Use nullish coalescing operator X-Git-Tag: v1.0.1-0~50 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=863cef2221eeab3c92506cc02dec1abd87abaa36;p=e-mobility-charging-stations-simulator.git WorkerFactory.ts: Use nullish coalescing operator Signed-off-by: Jérôme Benoit --- diff --git a/src/worker/WorkerFactory.ts b/src/worker/WorkerFactory.ts index 41fa1d89..242121fb 100644 --- a/src/worker/WorkerFactory.ts +++ b/src/worker/WorkerFactory.ts @@ -17,22 +17,14 @@ export default class WorkerFactory { } switch (workerProcessType) { case WorkerProcessType.WORKER_SET: - if (Utils.isUndefined(options.elementsPerWorker)) { - options.elementsPerWorker = 1; - } + options.elementsPerWorker = options.elementsPerWorker ?? 1; return new WorkerSet(workerScript, options.elementsPerWorker); case WorkerProcessType.STATIC_POOL: - if (Utils.isUndefined(options.poolMaxSize)) { - options.poolMaxSize = 16; - } + options.poolMaxSize = options.poolMaxSize ?? 16; return new WorkerStaticPool(workerScript, options.poolMaxSize); case WorkerProcessType.DYNAMIC_POOL: - if (Utils.isUndefined(options.poolMinSize)) { - options.poolMinSize = 4; - } - if (Utils.isUndefined(options.poolMaxSize)) { - options.poolMaxSize = 16; - } + options.poolMinSize = options.poolMinSize ?? 4; + options.poolMaxSize = options.poolMaxSize ?? 16; return new WorkerDynamicPool(workerScript, options.poolMinSize, options.poolMaxSize); default: return null;