scb2promise
v0.1.1
Published
callback promise async
Downloads
2
Readme
scb2promise
transfer callback async function to a function which return a promise
usage
$ npm i -S scb2promise
example
scb2promise(fs.readFile)(filename).than(buffer => {
const fileContent = buffer.toString();
}, err => {
console.error(err);
});
which is equalent to :
fs.readFile(filename, (buffer, err) => {
if (err) {
console.log(err);
}
const fileContent = buffer.toString();
});
notation
the callback function must follow the laws below:
callback is the last param
callback params should like
fs
API which receive (err, data)