# workerize

> Run a module in a Web Worker.

Latest version **0.1.8** (published 2019-12-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install workerize
pnpm add workerize
yarn add workerize
bun add workerize
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.8 |
| Published | 2019-12-28 |
| First published | 2018-01-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 26.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4376 |
| Author | Jason Miller |
| Maintainers | developit |
| Keywords | worker, web workers, threads |

## Links

- npm: https://www.npmjs.com/package/workerize
- Repository: https://github.com/developit/workerize
- Homepage: https://github.com/developit/workerize#readme
- Issues: https://github.com/developit/workerize/issues
- npm.io page: https://npm.io/package/workerize

## Alternatives

- [cron](https://npm.io/package/cron.md) — 4.9M weekly downloads
- [@vercel/queue](https://npm.io/package/@vercel/queue.md) — 731.6K weekly downloads
- [create-sonicjs](https://npm.io/package/create-sonicjs.md) — 1.6K weekly downloads
- [@exellix/jobs-api](https://npm.io/package/@exellix/jobs-api.md) — 941 weekly downloads
- [@forwardimpact/libskill](https://npm.io/package/@forwardimpact/libskill.md) — 575 weekly downloads

## Recent versions

- 0.1.8 (latest) — 2019-12-28
- 0.1.7 — 2018-02-01
- 0.1.6 — 2018-01-24
- 0.1.5 — 2018-01-19
- 0.1.4 — 2018-01-19
- 0.1.3 — 2018-01-17
- 0.1.2 — 2018-01-10
- 0.1.1 — 2018-01-10
- 0.1.0 — 2018-01-09

## README

<h2 align="center">
  💖 Using Webpack? You want <a href="https://github.com/developit/workerize-loader">workerize-loader ➡️</a>
</h2>

<img src="https://i.imgur.com/MBlHoDp.jpg" width="1358" alt="workerize">

# Workerize [![npm](https://img.shields.io/npm/v/workerize.svg?style=flat)](https://www.npmjs.org/package/workerize) [![travis](https://travis-ci.org/developit/workerize.svg?branch=master)](https://travis-ci.org/developit/workerize)

> Moves a module into a Web Worker, automatically reflecting exported functions as asynchronous proxies.

- Bundles a tiny, purpose-built RPC implementation into your app
- If exported module methods are already async, signature is unchanged
- Supports synchronous and asynchronous worker functions
- Works beautifully with async/await
- Just **800 bytes** of gzipped ES3


## Install

```sh
npm install --save workerize
```


### Usage

Pass either a function or a string containing code.

**worker.js**:

```js
let worker = workerize(`
	export function add(a, b) {
		// block for half a second to demonstrate asynchronicity
		let start = Date.now();
		while (Date.now()-start < 500);
		return a + b;
	}
`);

(async () => {
	console.log('3 + 9 = ', await worker.add(3, 9));
	console.log('1 + 2 = ', await worker.add(1, 2));
})();
```

### License

[MIT License](https://oss.ninja/mit/developit/) © [Jason Miller](https://jasonformat.com)

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