From: Jérôme Benoit Date: Thu, 27 Jul 2023 12:17:39 +0000 (+0200) Subject: refactor: make TS example compatible with latest ES version X-Git-Tag: v2.6.21~17 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=1adc6af72c087b9412e625bc9576be67d40e7397;hp=d66d8d9da006e36000bc019b4688d69953e7a52f;p=poolifier.git refactor: make TS example compatible with latest ES version Signed-off-by: Jérôme Benoit --- diff --git a/examples/typescript/pool.ts b/examples/typescript/pool.ts index 54b437ab..a53857c0 100644 --- a/examples/typescript/pool.ts +++ b/examples/typescript/pool.ts @@ -1,4 +1,5 @@ -import { join } from 'path' +import { dirname, join } from 'path' +import { fileURLToPath } from 'url' import type { MyData, MyResponse } from './worker' import { DynamicThreadPool, @@ -8,7 +9,7 @@ import { export const fixedPool = new FixedThreadPool>( availableParallelism(), - join(__dirname, 'worker.js'), + join(dirname(fileURLToPath(import.meta.url)), 'worker.js'), { errorHandler: (e: Error) => { console.error(e) @@ -22,7 +23,7 @@ export const fixedPool = new FixedThreadPool>( export const dynamicPool = new DynamicThreadPool>( Math.floor(availableParallelism() / 2), availableParallelism(), - join(__dirname, 'worker.js'), + join(dirname(fileURLToPath(import.meta.url)), 'worker.js'), { errorHandler: (e: Error) => { console.error(e)