A simple and intuitive way to utilize worker threads in Node.js with TypeScript.
MIT License
npm i threadosaurus
Here's a quick example of how to use Threadosaurus:
import { CreateThreadosaurus } from 'threadosaurus';
import SampleWorkerThreadClass from './SampleWorkerThreadClass';
const worker = CreateThreadosaurus(SampleWorkerThreadClass);
console.log(await worker.greet('LJ and NJ'));
In SampleWorkerThreadClass.ts
:
import { Threadosaurus } from 'threadosaurus';
export default class SampleWorkerThreadClass implements Threadosaurus {
async greet(name: string): Promise<string> {
return Promise.resolve(`Hello ${name} from worker thread!`);
}
get__filename(): string {
return __filename;
}
}
When using Threadosaurus, please keep the following limitations in mind:
MIT