Created
November 15, 2014 03:41
-
-
Save poying/17834057283903662621 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 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