Execute tasks on web Workers without seperate files. In browsers without Worker
support it fallbacks to iframe
.
Nodejs support using child_process
is under way.
npm install async-task
var AsyncTask = require( 'async-task' )
var task = new AsyncTask({
doInBackground: function( a, b ) {
return a + b
}
})
task.execute(1, 2)
.then(function( result ) {
result === 3
})
.catch( handleException )
Creates a new AsyncTask
options.doInBackground
The work(function) to be done in the worker.options.keepAlive
Keep worker alive so.execute
can be called multiple times.
Execute the doInBackground
function with supplied args.
doInBackground
can return a promise or maybe even agenerator*
so you can iterate overasyncTask.execute
- Nodejs support using child_process
Partially made, with <3 at: