From: Jérôme Benoit Date: Fri, 7 Apr 2023 10:08:40 +0000 (+0200) Subject: refactor: check for null and undefined X-Git-Tag: v2.4.3~7 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=b1989cfdf9af9f2c5e01b9a3f7c81b8c3ed78cb4;p=poolifier.git refactor: check for null and undefined Signed-off-by: Jérôme Benoit --- 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()