Skip to content

Instantly share code, notes, and snippets.

@lsongdev
Last active January 12, 2016 03:39
Show Gist options
  • Save lsongdev/5941c6bd56526805d5f0 to your computer and use it in GitHub Desktop.
Save lsongdev/5941c6bd56526805d5f0 to your computer and use it in GitHub Desktop.
warp callback style function to promise .
/**
* [promiseify description]
* @param {[type]} creator [description]
* @return {[type]} [description]
*/
module.exports = function promiseify(creator){
return new Promise(function(accept, reject){
creator.call(this, function(err, res){
if(err) return reject(err);
accept(res);
});
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment