A simple shorthand to use Node worker_threads.
For now there is only support for ts-node.
Typescript still doesn't offer worker_threads support. To use them, you need to call a .js file to register on ts-node and then from this file call the .ts worker. To decrease verbosity you can use this package.
npm install ts-worker
import TSWorker from 'ts-worker';
import { Worker } from 'worker_threads'; // Just for typechecking
import TSWorker from 'ts-worker';
const worker: Worker = TSWorker('worker.ts', {
workerData: {
foo: 'bar'
}
});
worker.on('message', msg => console.log(msg));