Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Node.js Design Patterns

You're reading from   Node.js Design Patterns Master a series of patterns and techniques to create modular, scalable, and efficient applications

Arrow left icon
Product type Paperback
Published in Dec 2014
Publisher Packt
ISBN-13 9781783287314
Length 454 pages
Edition 1st Edition
Languages
Tools
Concepts
Arrow right icon
Author (1):
Arrow left icon
Mario Casciaro Mario Casciaro
Author Profile Icon Mario Casciaro
Mario Casciaro
Arrow right icon
View More author details
Toc

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

Promises

  • Greatly simplify the most common control flow patterns

  • Robust error handling

  • Part of the ES6 specification

  • Guarantee deferred invocation of onFulfilled and onRejected

  • Might require an external dependency

  • Require to promisify callback-based...

You have been reading a chapter from
Node.js Design Patterns
Published in: Dec 2014
Publisher: Packt
ISBN-13: 9781783287314
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime