build(deps-dev): apply updates
[poolifier.git] / benchmarks / internal / thread-worker.mjs
CommitLineData
a449b585 1import { isMainThread } from 'node:worker_threads'
ded253e2 2
8a970421 3import { ThreadWorker } from '../../lib/index.mjs'
d35e5717 4import { TaskFunctions } from '../benchmarks-types.cjs'
0804b9b4 5import { executeTaskFunction } from '../benchmarks-utils.mjs'
8a970421 6
041dc05b 7const taskFunction = data => {
8a970421 8 data = data || {}
66566c5d 9 data.function = data.function || TaskFunctions.factorial
f1c674cd 10 data.debug = data.debug || false
dbca3be9 11 const res = executeTaskFunction(data)
3a502712 12 // eslint-disable-next-line @typescript-eslint/no-unused-expressions
f1c674cd
JB
13 data.debug === true &&
14 console.debug(`This is the main thread ${isMainThread}`)
30b963d4 15 return res
8a970421
JB
16}
17
dbca3be9 18export default new ThreadWorker(taskFunction)