From: Jérôme Benoit Date: Thu, 29 Aug 2024 20:38:33 +0000 (+0200) Subject: docs(README.md): fix worker example export X-Git-Tag: v4.2.8~5 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=a5844a0fffdb82f3890ff87fd0a75860edc20eea;p=poolifier.git docs(README.md): fix worker example export Signed-off-by: Jérôme Benoit --- diff --git a/README.md b/README.md index 6ba572db..c5d78d14 100644 --- a/README.md +++ b/README.md @@ -107,8 +107,8 @@ function yourFunction(data) { return { ok: 1 } } -module.exports = new ThreadWorker(yourFunction, { - maxInactiveTime: 60000 +export default new ThreadWorker(yourFunction, { + maxInactiveTime: 60000, }) ``` @@ -120,7 +120,7 @@ import { DynamicThreadPool, FixedThreadPool, PoolEvents, availableParallelism } // a fixed worker_threads pool const pool = new FixedThreadPool(availableParallelism(), './yourWorker.js', { onlineHandler: () => console.info('worker is online'), - errorHandler: e => console.error(e) + errorHandler: e => console.error(e), }) pool.emitter?.on(PoolEvents.ready, () => console.info('Pool is ready')) @@ -129,7 +129,7 @@ pool.emitter?.on(PoolEvents.busy, () => console.info('Pool is busy')) // or a dynamic worker_threads pool const pool = new DynamicThreadPool(Math.floor(availableParallelism() / 2), availableParallelism(), './yourWorker.js', { onlineHandler: () => console.info('worker is online'), - errorHandler: e => console.error(e) + errorHandler: e => console.error(e), }) pool.emitter?.on(PoolEvents.full, () => console.info('Pool is full'))