1.1.1 • Published 5 years ago

mthread v1.1.1

Weekly downloads
-
License
MIT
Repository
-
Last release
5 years ago

Multithread or mthread

A simple Multithread with Web Worker based on Events.

Install

# npm
npm install mthread --save

# yarn
yarn add mthread

Usage (browser)

index.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

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

1.1.1

5 years ago

1.1.0

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

6 years ago