scb2promise

0.1.1 • Public • Published

scb2promise

transfer callback async function to a function which return a promise

npm version build status npm downloads

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)

Readme

Keywords

none

Package Sidebar

Install

npm i scb2promise

Weekly Downloads

0

Version

0.1.1

License

ISC

Last publish

Collaborators

  • hzongquan