From 1adc6af72c087b9412e625bc9576be67d40e7397 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Thu, 27 Jul 2023 14:17:39 +0200 Subject: [PATCH] refactor: make TS example compatible with latest ES version MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- examples/typescript/pool.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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) -- 2.34.1