Backgroundify
Execute long synchronous functions in background node processes.
Sometimes you have a big long synchronous function (e.g. JavaScript compilation using UglifyJS) but you don't want it locking up the main thread of your node application.
Use backgroundify to move that function onto a background process.
Usage
backgroundify(pathToModule[, processTitle, numProcesses ])
- pathToModule is evaluated relative to the file in which backgroundify is required
- numProcess defaults to
max(1, numCpus - 1)
module.exports = function(input){
return output;
};
var backgroundify = requlre('backgroundify');
var fn = backgroundify('./path/to/fn', 'optional-process-title', 4);
fn(input, function(err, output){
});