From: Jérôme Benoit Date: Sat, 30 Sep 2023 10:25:10 +0000 (+0200) Subject: refactor: null -> undefined where appropriate X-Git-Tag: v2.7.5~17 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=fefd3cef3596e4e79dfeea1a1d6dfa39726e2ef5;p=poolifier.git refactor: null -> undefined where appropriate Signed-off-by: Jérôme Benoit --- diff --git a/benchmarks/benchmarks-utils.js b/benchmarks/benchmarks-utils.js index aaf7521f..48311a3f 100644 --- a/benchmarks/benchmarks-utils.js +++ b/benchmarks/benchmarks-utils.js @@ -64,7 +64,7 @@ const runPoolifierPool = async (pool, { taskExecutions, workerData }) => { if (executions === taskExecutions) { resolve({ ok: 1 }) } - return null + return undefined }) .catch(err => { console.error(err) @@ -151,6 +151,7 @@ const runPoolifierPoolBenchmark = async ( LIST_FORMATTER.format(this.filter('fastest').map('name')) ) await pool.destroy() + pool = undefined resolve() }) .run({ async: true }) diff --git a/examples/javascript/dynamicExample.js b/examples/javascript/dynamicExample.js index 2783c171..e170f59c 100644 --- a/examples/javascript/dynamicExample.js +++ b/examples/javascript/dynamicExample.js @@ -38,7 +38,7 @@ for (let i = 1; i <= iterations; i++) { console.info(`The pool was busy for ${poolBusy} times`) return pool.destroy() } - return null + return undefined }) .catch(err => console.error(err)) } diff --git a/examples/javascript/fixedExample.js b/examples/javascript/fixedExample.js index 8aab9cb7..55ed724d 100644 --- a/examples/javascript/fixedExample.js +++ b/examples/javascript/fixedExample.js @@ -30,7 +30,7 @@ for (let i = 1; i <= iterations; i++) { console.info(`The pool was busy for ${poolBusy} times`) return pool.destroy() } - return null + return undefined }) .catch(err => console.error(err)) } diff --git a/examples/typescript/http-server-pool/express-cluster/src/main.ts b/examples/typescript/http-server-pool/express-cluster/src/main.ts index 86560455..7bdc56da 100644 --- a/examples/typescript/http-server-pool/express-cluster/src/main.ts +++ b/examples/typescript/http-server-pool/express-cluster/src/main.ts @@ -22,7 +22,7 @@ const pool = new FixedClusterPool( `Express is listening in cluster worker on port ${response?.port}` ) } - return null + return undefined }) .catch(error => { console.error('Express failed to start in cluster worker:', error) diff --git a/examples/typescript/http-server-pool/express-hybrid/src/main.ts b/examples/typescript/http-server-pool/express-hybrid/src/main.ts index 08563f4b..561aab5d 100644 --- a/examples/typescript/http-server-pool/express-hybrid/src/main.ts +++ b/examples/typescript/http-server-pool/express-hybrid/src/main.ts @@ -41,7 +41,7 @@ const pool = new FixedClusterPool( `Express is listening in cluster worker on port ${response?.port}` ) } - return null + return undefined }) .catch(error => { console.error('Express failed to start in cluster worker:', error) diff --git a/examples/typescript/http-server-pool/fastify-cluster/src/main.ts b/examples/typescript/http-server-pool/fastify-cluster/src/main.ts index 88167a3c..eb772035 100644 --- a/examples/typescript/http-server-pool/fastify-cluster/src/main.ts +++ b/examples/typescript/http-server-pool/fastify-cluster/src/main.ts @@ -22,7 +22,7 @@ const pool = new FixedClusterPool( `Fastify is listening in cluster worker on port ${response.port}` ) } - return null + return undefined }) .catch(error => { console.error('Fastify failed to start in cluster worker:', error) diff --git a/examples/typescript/http-server-pool/fastify-hybrid/src/main.ts b/examples/typescript/http-server-pool/fastify-hybrid/src/main.ts index 66be31a8..b700bdbb 100644 --- a/examples/typescript/http-server-pool/fastify-hybrid/src/main.ts +++ b/examples/typescript/http-server-pool/fastify-hybrid/src/main.ts @@ -41,7 +41,7 @@ const pool = new FixedClusterPool( `Fastify is listening in cluster worker on port ${response.port}` ) } - return null + return undefined }) .catch(error => { console.error('Fastify failed to start in cluster worker:', error) diff --git a/examples/typescript/websocket-server-pool/ws-cluster/src/main.ts b/examples/typescript/websocket-server-pool/ws-cluster/src/main.ts index 6187d71f..5b4e7b5e 100644 --- a/examples/typescript/websocket-server-pool/ws-cluster/src/main.ts +++ b/examples/typescript/websocket-server-pool/ws-cluster/src/main.ts @@ -22,7 +22,7 @@ const pool = new FixedClusterPool( `WebSocket server is listening in cluster worker on port ${response.port}` ) } - return null + return undefined }) .catch(error => { console.error( diff --git a/examples/typescript/websocket-server-pool/ws-hybrid/src/main.ts b/examples/typescript/websocket-server-pool/ws-hybrid/src/main.ts index 3adac7e8..0c31721a 100644 --- a/examples/typescript/websocket-server-pool/ws-hybrid/src/main.ts +++ b/examples/typescript/websocket-server-pool/ws-hybrid/src/main.ts @@ -41,7 +41,7 @@ const pool = new FixedClusterPool( `WebSocket server is listening in cluster worker on port ${response.port}` ) } - return null + return undefined }) .catch(error => { console.error( diff --git a/examples/typescript/websocket-server-pool/ws-hybrid/src/websocket-server-worker.ts b/examples/typescript/websocket-server-pool/ws-hybrid/src/websocket-server-worker.ts index ec6a3d18..46745d96 100644 --- a/examples/typescript/websocket-server-pool/ws-hybrid/src/websocket-server-worker.ts +++ b/examples/typescript/websocket-server-pool/ws-hybrid/src/websocket-server-worker.ts @@ -68,7 +68,7 @@ ClusterWorkerResponse data: response.data }) ) - return null + return undefined }) .catch(emptyFunction) break @@ -82,7 +82,7 @@ ClusterWorkerResponse data: response.data }) ) - return null + return undefined }) .catch(emptyFunction) break diff --git a/examples/typescript/websocket-server-pool/ws-worker_threads/src/main.ts b/examples/typescript/websocket-server-pool/ws-worker_threads/src/main.ts index c8478366..d5b2cc78 100644 --- a/examples/typescript/websocket-server-pool/ws-worker_threads/src/main.ts +++ b/examples/typescript/websocket-server-pool/ws-worker_threads/src/main.ts @@ -31,7 +31,7 @@ wss.on('connection', ws => { data: response.data }) ) - return null + return undefined }) .catch(emptyFunction) break @@ -45,7 +45,7 @@ wss.on('connection', ws => { data: response.data }) ) - return null + return undefined }) .catch(emptyFunction) break diff --git a/src/worker/abstract-worker.ts b/src/worker/abstract-worker.ts index 22e65bad..d0803b8d 100644 --- a/src/worker/abstract-worker.ts +++ b/src/worker/abstract-worker.ts @@ -374,7 +374,7 @@ export abstract class AbstractWorker< (this.opts.killHandler?.() as Promise) .then(() => { this.sendToMainWorker({ kill: 'success' }) - return null + return undefined }) .catch(() => { this.sendToMainWorker({ kill: 'failure' })