Callback hell is subjective, as heavily nested code can be perfectly fine sometimes. Asynchronous code is hellish when it becomes overly complex to manage the flow. A good question to see how much "hell" you are in is: how much refactoring pain would I endure if
doAsync1? The goal isn't about removing levels of indentation but rather writing modular (and testable!) code that is easy to reason about and resilient.
The post was originally published on StrongLoop's blog, here: Managing Node.js Callback Hell with Promises, Generators and Other Approaches. StrongLoop's blog is worth subscribing to if you're a Node developer -- it has general tutorials and coverage of interesting npm modules.
Tim Oxley posted some comments discussing how to use
Function.prototype.bind as well.