2 const { FixedThreadPool, availableParallelism } = require('poolifier')
4 const pool = new FixedThreadPool(
5 availableParallelism(),
6 './multiFunctionWorker.cjs',
8 onlineHandler: () => console.info('worker is online'),
9 errorHandler: e => console.error(e)
14 .execute({ text: 'hello' }, 'fn0')
15 .then(res => console.info(res))
16 .catch(err => console.error(err))
18 .execute({ text: 'multiple functions' }, 'fn1')
19 .then(res => console.info(res))
20 .catch(err => console.error(err))
22 setTimeout(async () => await pool.destroy(), 3000)