0.1.1 • Published 9 years ago
scb2promise v0.1.1
scb2promise
transfer callback async function to a function which return a promise
usage
$ npm i -S scb2promiseexample
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
fsAPI which receive (err, data)
