// a fixed worker_threads pool
const pool = new FixedThreadPool(availableParallelism(), './yourWorker.js', {
- errorHandler: (e) => console.error(e),
+ errorHandler: e => console.error(e),
onlineHandler: () => console.info('worker is online')
})
// or a dynamic worker_threads pool
const pool = new DynamicThreadPool(Math.floor(availableParallelism() / 2), availableParallelism(), './yourWorker.js', {
- errorHandler: (e) => console.error(e),
+ errorHandler: e => console.error(e),
onlineHandler: () => console.info('worker is online')
})
// so you can easily switch from one to another
pool
.execute()
- .then((res) => {
+ .then(res => {
console.info(res)
})
- .catch((err) => {
+ .catch(err => {
console.error(err)
})
```