From: Jérôme Benoit Date: Sat, 3 Feb 2024 18:28:53 +0000 (+0100) Subject: test: fix TS type definitions X-Git-Tag: v3.1.20~17 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=ac35d84eacd6a5dec2373efb3afc083a73ea2c2e;p=poolifier.git test: fix TS type definitions Signed-off-by: Jérôme Benoit --- diff --git a/.vscode/settings.json b/.vscode/settings.json index 1ca6758d..c3f75102 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -19,6 +19,7 @@ "deregisters", "eventloop", "Fastify", + "fastpath", "FOSS", "Gitter", "inheritDoc", diff --git a/examples/typescript/pool.ts b/examples/typescript/pool.ts index 57898d98..144d5500 100644 --- a/examples/typescript/pool.ts +++ b/examples/typescript/pool.ts @@ -12,7 +12,7 @@ const workerFile = join( `worker${extname(fileURLToPath(import.meta.url))}` ) -export const fixedPool = new FixedThreadPool>( +export const fixedPool = new FixedThreadPool( availableParallelism(), workerFile, { @@ -25,7 +25,7 @@ export const fixedPool = new FixedThreadPool>( } ) -export const dynamicPool = new DynamicThreadPool>( +export const dynamicPool = new DynamicThreadPool( Math.floor(availableParallelism() / 2), availableParallelism(), workerFile, diff --git a/examples/typescript/worker.ts b/examples/typescript/worker.ts index 562b2147..79819d98 100644 --- a/examples/typescript/worker.ts +++ b/examples/typescript/worker.ts @@ -6,17 +6,17 @@ export interface MyData { export interface MyResponse { message: string - data: MyData + data?: MyData } -class MyThreadWorker extends ThreadWorker> { +class MyThreadWorker extends ThreadWorker { constructor () { - super(async (data: MyData) => await this.process(data), { + super(async (data?: MyData) => await this.process(data), { maxInactiveTime: 60000 }) } - private async process (data: MyData): Promise { + private async process (data?: MyData): Promise { return await new Promise(resolve => { setTimeout(() => { resolve({ message: 'Hello from Worker :)', data })