1.0.2 • Published 7 years ago
topromise v1.0.2
toPromise
convert a function to promise
Installation
$ npm install toPromise
API
require('toPromise');
let func = function (a, cb) {
if (a > 0) {
cb (null, Math.sqrt (a));
}
else {
cb (Error ('a is less than 0'));
}
};
func.promise(this,a,b)
.then(function(result){
//TODO:...
})
.catch(function(e){
//TODO:...
});
License
MIT