Skip to content
WebWorker to share the code of the main thread
JavaScript HTML
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
example
test
.gitignore
.travis.yml
README.md
index.js
package.json

README.md

OUROBOROS WORKER

Build Status NPM Version License

WebWorker to share the code of the main thread

Installation

$ npm install ouroboros-worker

API

  • run(mainThread: function, workerThread: function): void

Example

const OuroborosWorker = require("ouroboros-worker");

function mainThread(worker) {
  worker.postMessage("hello!"); // (1) send to the worker
  worker.onmessage = function(e) { // (4) receive from the worker
    console.log(e.data); // → good bye!    
  };
}

function workerThread(self) {
  self.onmessage = function(e) { // (2) receive from the main thread
    console.log(e.data); // → hello!
    self.postMessage("good bye!"); // (3) send to the main thread
  }
}

OuroborosWorker.run(mainThread, workerThread);

License

MIT

You can’t perform that action at this time.