WorkerFactory.ts: Use nullish coalescing operator
authorJérôme Benoit <jerome.benoit@sap.com>
Thu, 22 Apr 2021 20:42:05 +0000 (22:42 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Thu, 22 Apr 2021 20:42:05 +0000 (22:42 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/worker/WorkerFactory.ts

index 41fa1d89715444ca5cd69b07f6684789f63b2ecc..242121fbb289b64f54b45de0aa510146a96ccffc 100644 (file)
@@ -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<T>(workerScript, options.elementsPerWorker);
       case WorkerProcessType.STATIC_POOL:
-        if (Utils.isUndefined(options.poolMaxSize)) {
-          options.poolMaxSize = 16;
-        }
+        options.poolMaxSize = options.poolMaxSize ?? 16;
         return new WorkerStaticPool<T>(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<T>(workerScript, options.poolMinSize, options.poolMaxSize);
       default:
         return null;