require-async
v0.0.4
Published
Require any module or file and call it's functions async
Downloads
6
Readme
requireAsync
Call any function on another thread.
Installing
npm install requireAsync
Usage
var requireAsync = require('require-async');
var someModule = requireAsync('some-module');
var someFile = requireAsync('./file.js');
The parameters for the returned function are
func
- the function to call inside your required module or filecallback
- the last argument must be a callbackarguments
- list as many arguments between this and the callback, these will be passed to the function
Example usage
var requireAsync = require('require-async');
var bcrypt = requireAsync('bcryptjs');
bcrypt('hashSync', function(err, salt) {
if (err) {
throw err;
}
console.log(salt);
}, 'bacon', 8);
Tips
- Leave the function name blank (not null, not defined, blank) if the function is the default export.