# ts-worker

> Easily use worker_threads with Typescript

Latest version **1.0.3** (published 2020-02-20) · 0 weekly downloads

## Install

```sh
npm install ts-worker
pnpm add ts-worker
yarn add ts-worker
bun add ts-worker
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2020-02-20 |
| First published | 2020-02-19 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Maintainers | estevam31 |
| Keywords | typescript, worker_threads, worker, ts-worker, typescript-worker |

## Links

- npm: https://www.npmjs.com/package/ts-worker
- Repository: https://github.com/estevam31/ts-worker
- Homepage: https://github.com/estevam31/ts-worker#readme
- Issues: https://github.com/estevam31/ts-worker/issues
- npm.io page: https://npm.io/package/ts-worker

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 1.0.3 (latest) — 2020-02-20
- 1.0.2 — 2020-02-19
- 1.0.1 — 2020-02-19
- 1.0.0 — 2020-02-19
- 0.0.5-B4 — 2020-02-19
- 0.0.5-B3 — 2020-02-19
- 0.0.5-B2 — 2020-02-19
- 0.0.5-B1 — 2020-02-19
- 0.0.5 — 2020-02-19
- 0.0.4 — 2020-02-19
- 0.0.3 — 2020-02-19
- 0.0.2 — 2020-02-19
- 0.0.1 — 2020-02-19

## README

# :construction_worker: ts-worker

A simple shorthand to use Node <a href="https://nodejs.org/api/worker_threads.html">worker_threads</a>.

**For now there is only support for <a href="https://github.com/TypeStrong/ts-node">ts-node.</a>**

# 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

```bash
  npm install ts-worker
```

- Import:

```javascript
const TSWorker = require('ts-worker');
```

- ES6:

```javascript
import TSWorker from 'ts-worker';
```

## Instantiating a Worker

```javascript
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));
```

---
_Source: https://npm.io/package/ts-worker · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
