async-method
Advanced tools
Weekly downloads
Readme
Makes async methods work with callbacks and promises. You have a function on your class that expects a callback as last parameter? Wrap it using the asyncMethod and it returns a promise if the callback is omitted.
npm i async-method
// create a class
var MyClass = new Class({
multiply: asyncMethod(function(a, b, callback) {
process.nextTick(function() {
callback(null, a*b);
});
})
});
var myClassInstance = new MyClass();
// classic callback
myClassInstance.multiply(3, 5, function(err, result) {
});
// es6 promise
myClassInstance.multiply(3, 5).then(function(result) {
}).catch(function(err) {
});
FAQs
Makes async methods work with callbacks and promises
The npm package async-method receives a total of 479 weekly downloads. As such, async-method popularity was classified as not popular.
We found that async-method demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.