Bump expect from 26.4.2 to 26.5.0
[poolifier.git] / examples / yourWorker.js
index 5036d5746be21fe1b48310b7909f0f6f0fb057b3..ac3959d121f1fcfa123f1118374a1c4b3d2bcf4f 100644 (file)
@@ -1,19 +1,15 @@
 'use strict'
 const { ThreadWorker } = require('../lib/workers')
 
-class MyWorker extends ThreadWorker {
-  constructor () {
-    super((data) => {
-      for (let i = 0; i <= 10000; i++) {
-        const o = {
-          a: i
-        }
-        JSON.stringify(o)
-      }
-      // console.log('This is the main thread ' + isMainThread)
-      return { ok: 1 }
-    })
+function yourFunction (data) {
+  for (let i = 0; i <= 1000; i++) {
+    const o = {
+      a: i
+    }
+    JSON.stringify(o)
   }
+  // console.log('This is the main thread ' + isMainThread)
+  return { ok: 1 }
 }
 
-module.exports = new MyWorker()
+module.exports = new ThreadWorker(yourFunction)