Stream interface for web workers
Install with component(1):
$ component install jwerle/worker-stream
main.js
var node = document.getElementById('node');
var WorkerStream = require('worker-stream');
var wstream = WorkerStream('worker.js');
wstream.on('data', function (chunk) {
console.log(chunk)
});
wstream.write('biz')
worker.js
// import somefile to provide `WorkerStream'
importScripts(
'path/to/worker-stream/build.js'
);
var WorkerStream = require('worker-stream');
var stream = WorkerStream(self);
stream.on('data', function (chunk) {
console.log('worker: '+ chunk)
});
stream.write('foo');
worker
- A string path to a worker or an instance of aWorker
opts
- Stream options (optional)
MIT