X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=examples%2Ftypescript%2Fpool.ts;h=93774422b4500459715ec236c136c1601f13add4;hb=9bc1ca7575fb508018f641dfee8c9939beda517a;hp=a53857c0f311a63ff321b4ce08b9e1ef02465dcd;hpb=13ab5b87b0bb239bc696b724270b7ec0760ca5bb;p=poolifier.git diff --git a/examples/typescript/pool.ts b/examples/typescript/pool.ts index a53857c0..93774422 100644 --- a/examples/typescript/pool.ts +++ b/examples/typescript/pool.ts @@ -1,4 +1,4 @@ -import { dirname, join } from 'path' +import { dirname, extname, join } from 'path' import { fileURLToPath } from 'url' import type { MyData, MyResponse } from './worker' import { @@ -7,9 +7,14 @@ import { availableParallelism } from 'poolifier' +const workerFile = join( + dirname(fileURLToPath(import.meta.url)), + `worker${extname(fileURLToPath(import.meta.url))}` +) + export const fixedPool = new FixedThreadPool>( availableParallelism(), - join(dirname(fileURLToPath(import.meta.url)), 'worker.js'), + workerFile, { errorHandler: (e: Error) => { console.error(e) @@ -23,7 +28,7 @@ export const fixedPool = new FixedThreadPool>( export const dynamicPool = new DynamicThreadPool>( Math.floor(availableParallelism() / 2), availableParallelism(), - join(dirname(fileURLToPath(import.meta.url)), 'worker.js'), + workerFile, { errorHandler: (e: Error) => { console.error(e)