X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fworker%2FWorkerSet.ts;h=047d03ad0ee09aa9922e4b66667f34ddc7f5b8e6;hb=6a4032b5d8f3cbaa18d3beddcdfe9d335c1cba90;hp=c5df860ced4fc85b16e7067c805605b05db75e04;hpb=4c7c767b9ed625eee3e28f34bda8e63ecc4391b4;p=e-mobility-charging-stations-simulator.git diff --git a/src/worker/WorkerSet.ts b/src/worker/WorkerSet.ts index c5df860c..047d03ad 100644 --- a/src/worker/WorkerSet.ts +++ b/src/worker/WorkerSet.ts @@ -30,10 +30,7 @@ export class WorkerSet extends WorkerAbstract { */ 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 { 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 { 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();