Comparison

At this point of the chapter, we should have a better understanding of what options we have to tame the asynchronous nature of Node.js. Each one of the solutions presented has its own pros and cons. Let's summarize them in the following table:

Solutions

Pros

Cons

Plain JavaScript

  • Does not require any additional library or technology
  • Offers the best performances
  • Provides the best level of compatibility with third-party libraries
  • Allows the creation of ad hoc and more advanced algorithms
  • Might require extra code and relatively complex algorithms

Async

  • Simplifies the most common control flow patterns
  • Is still a callback-based solution
  • Good performances
  • Introduces an external dependency
  • Might still not be enough for advanced flows ...

Get Node.js Design Patterns now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.