# function-to-worker

> This package can get function and wrap it in web worker

Latest version **0.0.11** (published 2019-04-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install function-to-worker
pnpm add function-to-worker
yarn add function-to-worker
bun add function-to-worker
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.11 |
| Published | 2019-04-04 |
| First published | 2019-04-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 11.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Genrikh Fetischev |
| Maintainers | genrikh |
| Keywords | worker, promise, webworker, web worker |

## Links

- npm: https://www.npmjs.com/package/function-to-worker
- Repository: https://github.com/GenrikhFetischev/function-to-worker
- Issues: https://github.com/GenrikhFetischev/function-to-worker/issues
- npm.io page: https://npm.io/package/function-to-worker

## 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.0.11 (latest) — 2019-04-04
- 0.0.10 — 2019-04-04
- 0.0.9 — 2019-04-04
- 0.0.8 — 2019-04-03
- 0.0.7 — 2019-04-03
- 0.0.6 — 2019-04-03
- 0.0.5 — 2019-04-03
- 0.0.4 — 2019-04-03
- 0.0.3 — 2019-04-03
- 0.0.2 — 2019-04-03
- 0.0.0 — 2019-04-03

## README

# function-to-worker

**`function-to-worker`** is a package designed for run any synchronous functions in web workers scope. It lets to make calculations
without blocking main js thread.

## Usage

Package provide only one simple function which makes worker from passed function:

```javascript
import createWorker from "function-to-worker";

const wantToCalculateItInWorker = number => number + 1;
const calculateInWorker = createWorker(wantToCalculateItInWorker);
```

function _calculateInWorker_ from example above returns _Promise_ which will resolved or rejected with
value was returned by _wantToCalculateItInWorker_ function. So, we can use it like this:

```javascript
const addOneInWorker = async number => await calculateInWorker(number);
```

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