Created
November 15, 2014 03:18
-
-
Save poying/830d4efb4c65ac4aaba0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var callbackOrPromise = function (cb, fn) { | |
if (cb || typeof Promise === 'undefined') { | |
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