npm

Need private packages and team management tools?Check out npm Orgs. »

callback2promise

1.0.3 • Public • Published

callback2promise

Converts functions with node style callbacks to promise (es6)

installation

npm install callback2promise --save

usage

 
var c2p = require('callback2promise');
 
// ordinary function with any number of parameters and a callback at the end
var nodeStyleFunc = function(param1, param2, callback){
  setTimeout(
    function(){ 
      callback(null, 'done') 
    }, 200);
}
 
// convert the function to a promise
var promise = c2p(nodeStyleFunc)(param1, param2);
 
promise
  .then(result => console.log(result))
  .catch(err => console.log(err));
 

install

npm i callback2promise

Downloadsweekly downloads

2

version

1.0.3

license

ISC

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability