Simplified Webworker runner for one off tasks
Works in browsers supporting listed dependencies.
- Promise
- Worker
For now just copy index.js
from src
folder to your project
I am still working on publishing this.
// to create a worker pass WebWorker a function
var worker = WebWorker(function(input) {
var to = setTimeout(function() {
clearTimeout(to);
// wrk -> is a namespace inside worker
// wrk.done is an alias for self.postMessage
// @todo handle Typed arrays copy
wrk.done(input);
}, 1000);
});
function success(result) {
console.log(result);
}
function failure(reason) {
throw new Error(reason);
}
// worker returns a promise use it for xhrHttpRequest work
worker.run('arguments').then(success, failure);
npm test
Will be using airbnb style guide for this project with eslint.
Stay away from es6 until babel transpiler added.
- 0.1.0 Initial release
- add worker detection
- add babel builder for packaging
- come up with safe wrk.done abstraction
- cleaner /safer Worker(func) parser
- ...
- publish