From: Jérôme Benoit Date: Sat, 23 Dec 2023 17:56:31 +0000 (+0100) Subject: refactor: convert if...then...else to switch...case X-Git-Tag: v3.1.11~4 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=839b98b8d7b2a142da0841e9618b14c3e4e55c71;p=poolifier.git refactor: convert if...then...else to switch...case Signed-off-by: Jérôme Benoit --- diff --git a/src/pools/worker-node.ts b/src/pools/worker-node.ts index d80c03d8..c9ff0e70 100644 --- a/src/pools/worker-node.ts +++ b/src/pools/worker-node.ts @@ -132,13 +132,16 @@ export class WorkerNode }) this.closeMessageChannel() this.removeAllListeners() - if (this.info.type === WorkerTypes.thread) { - await this.worker.terminate?.() - } else if (this.info.type === WorkerTypes.cluster) { - this.registerOnceWorkerEventHandler('disconnect', () => { - this.worker.kill?.() - }) - this.worker.disconnect?.() + switch (this.info.type) { + case WorkerTypes.thread: + await this.worker.terminate?.() + break + case WorkerTypes.cluster: + this.registerOnceWorkerEventHandler('disconnect', () => { + this.worker.kill?.() + }) + this.worker.disconnect?.() + break } await waitWorkerExit }