# multee

> Turn node's multitasking modules, child_process and worker_threads into simple async functions

Latest version **0.2.4** (published 2021-02-06) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.4 |
| Published | 2021-02-06 |
| First published | 2020-06-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 5 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Rakuraku Jyo |
| Maintainers | rjyo |
| Keywords | child_process, worker_threads, task, thread, process |

## Links

- npm: https://www.npmjs.com/package/multee
- Repository: https://github.com/rjyo/multee
- Issues: https://github.com/rjyo/multee/issues
- npm.io page: https://npm.io/package/multee

## Dependencies (1)

- [uuid](https://npm.io/package/uuid.md) ^8.3.2

## 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.2.4 (latest) — 2021-02-06
- 0.2.3 — 2020-09-21
- 0.2.2 — 2020-07-21
- 0.2.1 — 2020-06-06
- 0.2.0 — 2020-06-06
- 0.1.5 — 2020-06-05
- 0.1.4 — 2020-06-05
- 0.1.3 — 2020-06-05
- 0.1.2 — 2020-06-01
- 0.1.1 — 2020-06-01

## README

[![CI](https://github.com/rjyo/multee/workflows/CI/badge.svg)](https://github.com/rjyo/multee/actions) [![Maintainability](https://api.codeclimate.com/v1/badges/a30197a15f88eb66c546/maintainability)](https://codeclimate.com/github/rjyo/multee/maintainability)

# multee

multee is a "battery" API. It turns node's multitasking modules, namingly `child_process` and `worker_threads`, into simple async functions.

## Why multee helps

Without `multee`, you need to listen to messages from your threads/processes, and it is hard to integrate the listener to other part of your code. Also, when there are multiple operations inside the worker, we have to implement the dispatching logic inside the message listener.

The code will look like below without `multee`

```javascript
// worker.js
process.on('message', (msg) => {
  // do heavy load job
  process.send(job_result)
})

// master.js
const child = fork('./worker')

process.on('message', (msg) => {
  // if is job result
  part2(msg)
})

function part1() {
  child.send(payload_for_worker)
}

function part2(result) {
  // do the rest with result
}
```

And with `multee`, it's just as easy as calling an async function.

```javascript
// worker.js
const Multee = require('multee')
const multee = Multee('worker') // worker_threads, use 'child' for child_process

export const jobA = multee.createHandler('jobA', () => {
  // do the heavy load here
})

module.exports = () => {
  const worker = multee.start(__filename)
  return { test: jobA(worker) }
}

// master.js
async function partA() {
  const worker = require('./worker')
  const result = await worker.jobA()
  // do the rest with result
}
```

## Out-of-the-box Typescript support

`multee` works with Typescript. As you can't directly start worker_threads from Typescript, `multee` includes the battery to handle that. note: `ts-node` needed as a peer dependency when using Typescript.


## License

MIT

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