Package lock to 2.0.0 and removing other full keywords
[poolifier.git] / examples / staticExample.js
index b9f7503fc8a4d656aa069f181c6ebdd679855d89..d81e3484e89946374cc3056208e4d888a0162722 100644 (file)
@@ -1,4 +1,4 @@
-const FixedThreadPool = require('../lib/fixed')
+const { FixedThreadPool } = require('poolifier')
 let resolved = 0
 const pool = new FixedThreadPool(15, './yourWorker.js', {
   errorHandler: e => console.error(e),
@@ -8,10 +8,14 @@ const pool = new FixedThreadPool(15, './yourWorker.js', {
 const start = Date.now()
 const iterations = 1000
 for (let i = 0; i <= iterations; i++) {
-  pool.execute({}).then(res => {
-    resolved++
-    if (resolved === iterations) {
-      console.log('Time take is ' + (Date.now() - start))
-    }
-  })
+  pool
+    .execute({})
+    .then(res => {
+      resolved++
+      if (resolved === iterations) {
+        return console.log('Time take is ' + (Date.now() - start))
+      }
+      return null
+    })
+    .catch(err => console.error(err))
 }