Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Node.js High Performance

You're reading from   Node.js High Performance Take your application to the next level of high performance using the extensive capabilities of Node.js

Arrow left icon
Product type Paperback
Published in Aug 2015
Publisher
ISBN-13 9781785286148
Length 136 pages
Edition 1st Edition
Tools
Arrow right icon
Author (1):
Arrow left icon
Diogo Resende Diogo Resende
Author Profile Icon Diogo Resende
Diogo Resende
Arrow right icon
View More author details
Toc

Node.js patterns

Because of the structure and API model of the Node.js platform, some patterns are more biased or natural. The most obvious are the event-driven and the event stream patterns. They're not enforced but strongly engrained in the core API, and you're forced to use it in some parts of your application, so it's better to know how they work individually, how they work together, and how you can benefit from them.

Using the core API, you can access the filesystem, for example, to read a file with a single method and a callback; or you can request a read stream and then check the data and end events or pipe the stream to somewhere else. This is very useful when, say, you don't want to look at the file and just want to serve it to a client. This architecture was designed to work for core modules such as http and net. Similarly, when listening for client connections, you'll have to listen for a connection event (unless you have defined a connection listener...

lock icon The rest of the chapter is locked
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
Banner background image