From 839b98b8d7b2a142da0841e9618b14c3e4e55c71 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sat, 23 Dec 2023 18:56:31 +0100 Subject: [PATCH] refactor: convert if...then...else to switch...case MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/pools/worker-node.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) 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 } -- 2.34.1