build(deps): apply updates
[e-mobility-charging-stations-simulator.git] / src / worker / WorkerSet.ts
index c5df860ced4fc85b16e7067c805605b05db75e04..047d03ad0ee09aa9922e4b66667f34ddc7f5b8e6 100644 (file)
@@ -30,10 +30,7 @@ export class WorkerSet extends WorkerAbstract<WorkerData> {
    */
   constructor(workerScript: string, workerOptions: WorkerOptions) {
     super(workerScript, workerOptions);
-    if (
-      this.workerOptions.elementsPerWorker === null ||
-      this.workerOptions.elementsPerWorker === undefined
-    ) {
+    if (this.workerOptions.elementsPerWorker == null) {
       throw new TypeError('Elements per worker is not defined');
     }
     if (!Number.isSafeInteger(this.workerOptions.elementsPerWorker)) {
@@ -95,6 +92,7 @@ export class WorkerSet extends WorkerAbstract<WorkerData> {
       await waitWorkerExit;
       this.emitter?.emit(WorkerSetEvents.stopped, this.info);
       this.emitter?.emitDestroy();
+      this.emitter?.removeAllListeners();
       this.started = false;
     }
   }
@@ -104,7 +102,7 @@ export class WorkerSet extends WorkerAbstract<WorkerData> {
     if (!this.started) {
       throw new Error('Cannot add a WorkerSet element: not started');
     }
-    if (!this.workerSet) {
+    if (this.workerSet == null) {
       throw new Error("Cannot add a WorkerSet element: 'workerSet' property does not exist");
     }
     const workerSetElement = await this.getWorkerSetElement();