```js
// Before
-const DynamicThreadPool = require("poolifier/lib/dynamic");
+const DynamicThreadPool = require('poolifier/lib/dynamic')
// After
-const { DynamicThreadPool } = require("poolifier/lib/dynamic");
+const { DynamicThreadPool } = require('poolifier/lib/dynamic')
```
But you should always prefer just using
```js
-const { DynamicThreadPool } = require("poolifier");
+const { DynamicThreadPool } = require('poolifier')
```
#### New type definitions for input data and response
// 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 easy switch from one to another
pool
.execute()
- .then(res => {
+ .then((res) => {
console.info(res)
})
- .catch(err => {
+ .catch((err) => {
console.error(err)
})
```