Skip to content

Instantly share code, notes, and snippets.

@poying
Created November 15, 2014 03:37
Show Gist options
  • Save poying/26dfa50175f703fe26d5 to your computer and use it in GitHub Desktop.
Save poying/26dfa50175f703fe26d5 to your computer and use it in GitHub Desktop.
var Promise = require('native-or-bluebird');
var callbackOrPromise = function (cb, fn) {
if (cb) {
return fn(cb);
}
return new Promise(function (resolve, reject) {
fn(function (err, res) {
err ? reject(err) : resolve(res);
});
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment