Here's a trivial example of calculating the nth fibonacci number. There's some
code you can browserify in the
example folder too.
// index.jsvar fibonacci =
// setup.jsvar parent =var worker =moduleexports =
// fibonacci.jsmoduleexports =
require('worker-query/child')(request(data, done(err, result[, transfers])))
Creates and returns a worker template: calling that function on a clean worker
will set up everything you need on the worker's end.
request is a function
called every time data is requested with the
data supplied and a
callback you should call with the result.
get = require('worker-query/parent')(worker)
Takes a fresh
worker and sets up everything you need on the parent script's
end to request data from it. Returns a function you can use to request data.
get(data, callback(err, result)[, transfers])
data to the worker - when it's ready, it should return the
callback. Optionally, you can pass through an array of transferable
objects as a third argument for better performance.