ouroboros-worker

1.0.0 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i ouroboros-worker

Weekly Downloads

0

Version

1.0.0

License

MIT

Last publish

Collaborators

  • mohayonao