install @gimmi7/ts-worker-pool using npm:
npm install @gimmi7/ts-worker-poolconsole
npm install @gimmi7/ts-worker-pool --save
`
Import WorkerPool and run a method with worker_threads pool:
`js
import { WorkerPool } from '@gimmi7/ts-worker-pool';
import { moduleurl } from './task.js';
const workerpool = WorkerPool.defaultPool()
const greeting = await workerpool.run(moduleurl, "saihi", "gimmi7")
console.log(greeting) // will print "hi,gimmi7"
`
task.ts
`js
export function saihi(name: string): string {
return "hi," + name;
}
export const moduleurl = import.meta.url
``