Web worker API wrapper


Web worker API wrapper.

$ component install component/worker
var Worker = require('worker');
var worker = new Worker('work.js');
worker.on('message', function(msge){
  if (!msg.progress) return'message');
worker.send({ id: 1 });

Initialize a worker with the given script.

Send a message to the worker.

worker.send({ string: 'hello' });
worker.send({ string: 'world' });

Send a request message to the worker with the given callback. When using the request/response paradigm you should pass the property back with your response so that the correct callback may be invoked:

onmessage = function(e) {
    postMessage({ id:, value: });
  }, 500);

Terminate the worker.