Skip to content

Instantly share code, notes, and snippets.

@poying
Created November 15, 2014 03:41
Show Gist options
  • Save poying/17834057283903662621 to your computer and use it in GitHub Desktop.
Save poying/17834057283903662621 to your computer and use it in GitHub Desktop.
var myModule = module.exports;
// 修改前
myModule.callbackMethod = function (arg1, arg2, cb) {
// 作一些事情
asyncFunction(function () {
// 一些異步操作
asyncFunction(function () {
// 執行完成
cb();
});
});
};
// 修改後
myModule.callbackMethod = function (arg1, arg2, cb) {
return promiseOrCallback(cb, function (cb) {
// 作一些事情
asyncFunction(function () {
// 一些異步操作
asyncFunction(function () {
// 執行完成
cb();
});
});
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment