1.0.3 • Published 4 years ago

ts-worker v1.0.3

Weekly downloads
55
License
-
Repository
github
Last release
4 years ago

:construction_worker: ts-worker

A simple shorthand to use Node worker_threads.

For now there is only support for ts-node.

Why?

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.

Usage

  npm install ts-worker
  • Import:
const TSWorker = require('ts-worker');
  • ES6:
import TSWorker from 'ts-worker';

Instantiating a 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));
1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.0.5-B4

4 years ago

0.0.5-B3

4 years ago

0.0.5-B2

4 years ago

0.0.5-B1

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago