chore: migrate to eslint 9
[poolifier.git] / benchmarks / internal / thread-worker.mjs
1 import { isMainThread } from 'node:worker_threads'
2
3 import { ThreadWorker } from '../../lib/index.mjs'
4 import { TaskFunctions } from '../benchmarks-types.cjs'
5 import { executeTaskFunction } from '../benchmarks-utils.mjs'
6
7 const taskFunction = data => {
8 data = data || {}
9 data.function = data.function || TaskFunctions.factorial
10 data.debug = data.debug || false
11 const res = executeTaskFunction(data)
12 // eslint-disable-next-line @typescript-eslint/no-unused-expressions
13 data.debug === true &&
14 console.debug(`This is the main thread ${isMainThread}`)
15 return res
16 }
17
18 export default new ThreadWorker(taskFunction)