refactor: null -> undefined where appropriate
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Sat, 30 Sep 2023 10:25:10 +0000 (12:25 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Sat, 30 Sep 2023 10:25:10 +0000 (12:25 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
12 files changed:
benchmarks/benchmarks-utils.js
examples/javascript/dynamicExample.js
examples/javascript/fixedExample.js
examples/typescript/http-server-pool/express-cluster/src/main.ts
examples/typescript/http-server-pool/express-hybrid/src/main.ts
examples/typescript/http-server-pool/fastify-cluster/src/main.ts
examples/typescript/http-server-pool/fastify-hybrid/src/main.ts
examples/typescript/websocket-server-pool/ws-cluster/src/main.ts
examples/typescript/websocket-server-pool/ws-hybrid/src/main.ts
examples/typescript/websocket-server-pool/ws-hybrid/src/websocket-server-worker.ts
examples/typescript/websocket-server-pool/ws-worker_threads/src/main.ts
src/worker/abstract-worker.ts

index aaf7521ff3044807e02078c2cde0f45c584586b1..48311a3f04b773c0d6f540eaf659b2b00f3e08d7 100644 (file)
@@ -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 })
index 2783c171774e5d3b77cd16179d4a258d10ef9572..e170f59c00d35b24e54693da0a96f909f5dc73b8 100644 (file)
@@ -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))
 }
index 8aab9cb7a80544f2a83f2c7f348c6b711776bfba..55ed724d1e7e5bc4f0e204b5722cf480c1b5cad5 100644 (file)
@@ -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))
 }
index 86560455f33908f69aa762099bac010edf803d8a..7bdc56dab057e6b2bffa02d3d6085970f0244fd5 100644 (file)
@@ -22,7 +22,7 @@ const pool = new FixedClusterPool<WorkerData, WorkerResponse>(
               `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)
index 08563f4b2e753cefa3a331e9d0193be2a809f526..561aab5d2832217f50ec4304a858cc94bb72c40a 100644 (file)
@@ -41,7 +41,7 @@ const pool = new FixedClusterPool<ClusterWorkerData, ClusterWorkerResponse>(
               `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)
index 88167a3c091cdd8ee225b53d160e0ac5983a3d3b..eb7720350077b69d28918356389022b9d3c874ce 100644 (file)
@@ -22,7 +22,7 @@ const pool = new FixedClusterPool<WorkerData, WorkerResponse>(
               `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)
index 66be31a8aca6bef23391127b94391efc0b75361c..b700bdbb8bbcff9ff441960e5940c2d42c4c635a 100644 (file)
@@ -41,7 +41,7 @@ const pool = new FixedClusterPool<ClusterWorkerData, ClusterWorkerResponse>(
               `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)
index 6187d71fc3ae157177c2172e9bbdfdee3d5d56ad..5b4e7b5eab6e9c2d3bda8d46610e02bde2eee3f2 100644 (file)
@@ -22,7 +22,7 @@ const pool = new FixedClusterPool<WorkerData, WorkerResponse>(
               `WebSocket server is listening in cluster worker on port ${response.port}`
             )
           }
-          return null
+          return undefined
         })
         .catch(error => {
           console.error(
index 3adac7e819b3c6a35fd5fbd6f40196ea1df2846b..0c31721a417c575c65342c41cfad5ef837e8103c 100644 (file)
@@ -41,7 +41,7 @@ const pool = new FixedClusterPool<ClusterWorkerData, ClusterWorkerResponse>(
               `WebSocket server is listening in cluster worker on port ${response.port}`
             )
           }
-          return null
+          return undefined
         })
         .catch(error => {
           console.error(
index ec6a3d18736f119cb27f5e32988fe464f5d2d3d4..46745d9657cc9f700fc3f9ad79789b8323bf0715 100644 (file)
@@ -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
index c8478366a77dc18faa0219cbe809935c1ab5669a..d5b2cc78e8e4feda873602ea9b1074e581d3d8f9 100644 (file)
@@ -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
index 22e65bad63d213aa6b1bda6f0adc6a2a76401873..d0803b8da98d59ca9018cd190d6020d871dfad2e 100644 (file)
@@ -374,7 +374,7 @@ export abstract class AbstractWorker<
       (this.opts.killHandler?.() as Promise<void>)
         .then(() => {
           this.sendToMainWorker({ kill: 'success' })
-          return null
+          return undefined
         })
         .catch(() => {
           this.sendToMainWorker({ kill: 'failure' })