# mthread

> A simple Multithread with Web Worker based on Events

Latest version **1.1.1** (published 2019-01-05) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2019-01-05 |
| First published | 2018-11-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 20.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | oknoorap |

## Links

- npm: https://www.npmjs.com/package/mthread
- npm.io page: https://npm.io/package/mthread

## Recent versions

- 1.1.1 (latest) — 2019-01-05
- 1.1.0 — 2019-01-05
- 1.0.2 — 2018-12-31
- 1.0.1 — 2018-12-23
- 1.0.0 — 2018-11-02

## README

# Multithread or `mthread`
A simple Multithread with Web Worker based on Events.

## Install
```bash
# npm
npm install mthread --save

# yarn
yarn add mthread
```

## Usage (browser)
`index.html`:
```html
<!-- .... html content -->
<script defer src="https://unpkg.com/mthread/dist/mthread.min.js"></script>
<script defer type="module">
  const thread = new MultiThread('./worker.js')

  thread.on('pong', number => {
    console.log(`got reply from worker, x + y = ${number}`)
  })
  
  // Send ping with data
  thread.send('ping', {
    x: 1,
    y: 1
  })
</script>
```

`worker.js`
```javascript
importScripts('https://unpkg.com/mthread/dist/mthread.min.js')

const thread = new MultiThread(true)

thread.on('ping', ({ x, y }) => {
  thread.send('pong', x + y)
})
```

## License
MIT (c) 2018

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