callback-wrap
v1.0.0
Published
Wrapper for callback returning functions to transform them in promise returning functions.
Downloads
1
Readme
callback-wrap
Wrapper for callback returning functions to transform them in promise returning functions.
Installation
$ npm install callback-wrap
Example
var wrap = require('callback-wrap');
function cbkfn(a, b, c, cbk) {
if (a < b) {
return cbk(new Error('Error'));
}
return cbk(null, c);
}
var prmfn = wrap(cbkfn);
prmfn(4, 2, 3)
.then(
function (result) {
console.log(result);
},
function (err) {
console.log(err);
}
);
API
wrap(callbackFunction)
Wraps the callback function in a promise function that is returned.
License
MIT