Good resources on structuring asynchronous code?
One thing I keep running across is a stack of functions at the bottom of my code. I can man开发者_如何学Cge it pretty well but I think their are probably better standards and practice out there that will help when sharing code.
I was hoping to see how other people structure their code, or some resources on good techniques for writing async JS.
You could probably learn the most by reviewing the source code for some of the more popular Node modules on GitHub. Express and Connect come to mind. You could even look at the lib directory of Node itself.
Other than that, the best way to structure a 'stack' of functions that is starting to get overwhelming is to group the functions by purpose and place each group in its own module (and therefore, separate file).
精彩评论