build(deps-dev): apply updates
[poolifier.git] / benchmarks / internal / cluster-worker.cjs
CommitLineData
ab7bb4f8 1const { isPrimary } = require('node:cluster')
d35e5717
JB
2const { ClusterWorker } = require('../../lib/index.cjs')
3const { executeTaskFunction } = require('../benchmarks-utils.cjs')
4const { TaskFunctions } = require('../benchmarks-types.cjs')
57df5469 5
041dc05b 6const taskFunction = data => {
2d2e32c2 7 data = data || {}
66566c5d 8 data.function = data.function || TaskFunctions.factorial
f1c674cd 9 data.debug = data.debug || false
dbca3be9 10 const res = executeTaskFunction(data)
3a502712 11 // eslint-disable-next-line @typescript-eslint/no-unused-expressions
f1c674cd 12 data.debug === true && console.debug(`This is the main thread ${isPrimary}`)
30b963d4 13 return res
106744f7 14}
15
ab7bb4f8 16module.exports = new ClusterWorker(taskFunction)