Merge dependabot/npm_and_yarn/examples/typescript/http-server-pool/fastify-worker_thr...
[poolifier.git] / tests / worker-files / thread / testWorker.js
index c70069c7269f17d2f83069554d0e3fba5d2a15e6..3945589f80cb088306c278ffcd5610526a615f6a 100644 (file)
@@ -1,18 +1,15 @@
 'use strict'
-const { ThreadWorker, KillBehaviors } = require('../../../lib/index')
-const { isMainThread } = require('worker_threads')
+const { ThreadWorker, KillBehaviors } = require('../../../lib')
+const { executeTaskFunction } = require('../../test-utils')
+const { TaskFunctions } = require('../../test-types')
 
 function test (data) {
-  for (let i = 0; i <= 50; i++) {
-    const o = {
-      a: i
-    }
-    JSON.stringify(o)
-  }
-  return isMainThread
+  data = data || {}
+  data.function = data.function || TaskFunctions.jsonIntegerSerialization
+  return executeTaskFunction(data)
 }
 
 module.exports = new ThreadWorker(test, {
-  maxInactiveTime: 500,
-  killBehavior: KillBehaviors.HARD
+  killBehavior: KillBehaviors.HARD,
+  maxInactiveTime: 500
 })