chore: run lint fix
[poolifier.git] / examples / typescript / pool.ts
index a53857c0f311a63ff321b4ce08b9e1ef02465dcd..ab6d4f268b38a76520cf15b919948eae3e9eb924 100644 (file)
@@ -1,15 +1,20 @@
-import { dirname, join } from 'path'
+import { dirname, extname, join } from 'path'
 import { fileURLToPath } from 'url'
-import type { MyData, MyResponse } from './worker'
 import {
   DynamicThreadPool,
   FixedThreadPool,
   availableParallelism
 } from 'poolifier'
+import type { MyData, MyResponse } from './worker'
+
+const workerFile = join(
+  dirname(fileURLToPath(import.meta.url)),
+  `worker${extname(fileURLToPath(import.meta.url))}`
+)
 
 export const fixedPool = new FixedThreadPool<MyData, Promise<MyResponse>>(
   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<MyData, Promise<MyResponse>>(
 export const dynamicPool = new DynamicThreadPool<MyData, Promise<MyResponse>>(
   Math.floor(availableParallelism() / 2),
   availableParallelism(),
-  join(dirname(fileURLToPath(import.meta.url)), 'worker.js'),
+  workerFile,
   {
     errorHandler: (e: Error) => {
       console.error(e)