From b1989cfdf9af9f2c5e01b9a3f7c81b8c3ed78cb4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Fri, 7 Apr 2023 12:08:40 +0200 Subject: [PATCH] refactor: check for null and undefined MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- prepare.js | 2 +- src/pools/abstract-pool.ts | 4 ++-- src/worker/abstract-worker.ts | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/prepare.js b/prepare.js index 12846ca2..eef41216 100644 --- a/prepare.js +++ b/prepare.js @@ -1,4 +1,4 @@ -const isCIEnvironment = process.env.CI !== undefined +const isCIEnvironment = process.env.CI != null if (isCIEnvironment === false) { require('husky').install() } diff --git a/src/pools/abstract-pool.ts b/src/pools/abstract-pool.ts index afd7914e..ad21effb 100644 --- a/src/pools/abstract-pool.ts +++ b/src/pools/abstract-pool.ts @@ -380,9 +380,9 @@ export abstract class AbstractPool< */ protected workerListener (): (message: MessageValue) => void { return message => { - if (message.id !== undefined) { + if (message.id != null) { const promiseResponse = this.promiseResponseMap.get(message.id) - if (promiseResponse !== undefined) { + if (promiseResponse != null) { if (message.error != null) { promiseResponse.reject(message.error) } else { diff --git a/src/worker/abstract-worker.ts b/src/worker/abstract-worker.ts index 6a7a4325..51654179 100644 --- a/src/worker/abstract-worker.ts +++ b/src/worker/abstract-worker.ts @@ -81,18 +81,18 @@ export abstract class AbstractWorker< value: MessageValue, fn: (data: Data) => Response ): void { - if (value.data !== undefined && value.id !== undefined) { + if (value.data != null && value.id != null) { // Here you will receive messages if (this.opts.async === true) { this.runInAsyncScope(this.runAsync.bind(this), this, fn, value) } else { this.runInAsyncScope(this.run.bind(this), this, fn, value) } - } else if (value.parent !== undefined) { + } else if (value.parent != null) { // Save a reference of the main worker to communicate with it // This will be received once this.mainWorker = value.parent - } else if (value.kill !== undefined) { + } else if (value.kill != null) { // Here is time to kill this worker, just clearing the interval this.aliveInterval != null && clearInterval(this.aliveInterval) this.emitDestroy() -- 2.34.1