From: Jérôme Benoit Date: Sat, 25 Nov 2023 12:48:54 +0000 (+0100) Subject: refactor: use object destructuration in worker message listener X-Git-Tag: v3.0.8~2 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=b641345c7f4990af9f93a94159d55a922f6df973;p=poolifier.git refactor: use object destructuration in worker message listener Signed-off-by: Jérôme Benoit --- diff --git a/src/pools/abstract-pool.ts b/src/pools/abstract-pool.ts index 1759d03e..5da69ca1 100644 --- a/src/pools/abstract-pool.ts +++ b/src/pools/abstract-pool.ts @@ -1666,17 +1666,18 @@ export abstract class AbstractPool< */ protected workerMessageListener (message: MessageValue): void { this.checkMessageWorkerId(message) - if (message.ready != null && message.taskFunctionNames != null) { + const { workerId, ready, taskId, taskFunctionNames } = message + if (ready != null && taskFunctionNames != null) { // Worker ready response received from worker this.handleWorkerReadyResponse(message) - } else if (message.taskId != null) { + } else if (taskId != null) { // Task execution response received from worker this.handleTaskExecutionResponse(message) - } else if (message.taskFunctionNames != null) { + } else if (taskFunctionNames != null) { // Task function names message received from worker this.getWorkerInfo( - this.getWorkerNodeKeyByWorkerId(message.workerId) - ).taskFunctionNames = message.taskFunctionNames + this.getWorkerNodeKeyByWorkerId(workerId) + ).taskFunctionNames = taskFunctionNames } }