From a5844a0fffdb82f3890ff87fd0a75860edc20eea Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Thu, 29 Aug 2024 22:38:33 +0200 Subject: [PATCH] docs(README.md): fix worker example export MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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')) -- 2.34.1