test: improve event emitter tests
[poolifier.git] / examples / javascript / yourWorker.js
CommitLineData
27006a3d 1'use strict'
a449b585 2const { isMainThread } = require('node:worker_threads')
65d7a1c9 3const { ThreadWorker } = require('poolifier')
fd7ebd49
JB
4
5const debug = false
27006a3d 6
7a6a0a96 7function yourFunction () {
106744f7 8 for (let i = 0; i <= 1000; i++) {
9 const o = {
10 a: i
11 }
12 JSON.stringify(o)
13 }
1c132fec 14 debug === true && console.info(`This is the main thread ${isMainThread}`)
106744f7 15 return { ok: 1 }
16}
17
1f9a5a44 18module.exports = new ThreadWorker(yourFunction)