[NODE][Hands-on Node.js].pdf
(
584 KB
)
Pobierz
Hands-on Node.js
Pedro Teixeira
This book is for sale at
http://leanpub.com/hands-on-nodejs
This version was published on 2012-11-07
This is a Leanpub book. Leanpub helps authors to self-publish in-progress ebooks. We call this
idea Lean Publishing.
To learn more about Lean Publishing, go to http://leanpub.com/manifesto.
To learn more about Leanpub, go to http://leanpub.com.
©2011 - 2012 Leanpub
Tweet This Book!
Please help Pedro Teixeira by spreading the word about this book on
Twitter!
The suggested hashtag for this book is
#hands-on-nodejs.
Find out what other people are saying about the book by clicking on this link to search for this
hashtag on Twitter:
https://twitter.com/search/#hands-on-nodejs
Contents
Introduction
Why the sudden, exponential popularity? . . . . . . . . . . . . . . . . . . . . . . . . . . .
What does this book cover? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
What does this book not cover? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Source code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Where will this book lead you? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Chapter Overview
Why? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Starting up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Understanding Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
API Quick Tour . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Utilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Buffers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Event Emitter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Timers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Low-level File System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
HTTP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Streams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
TCP Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
UNIX Sockets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Datagrams (UDP) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Child Processes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Streaming HTTP Chunked Responses . . . . . . . . . . . . . . . . . . . . . . . . . .
TLS / SSL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
HTTPS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1
1
2
2
2
2
2
3
4
4
4
4
4
4
4
4
4
5
5
5
5
5
5
5
5
5
5
CONTENTS
Making Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Automated Unit Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Callback Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Why?
Why the event loop? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Solution 1: Create more call stacks . . . . . . . . . . . . . . . . . . . . . . . . . . .
Solution 2: Use event-driven I/O . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Why JavaScript? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
How I Learned to Stop Fearing and Love JavaScript . . . . . . . . . . . . . . . . . .
Function Declaration Styles . . . . . . . . . . . . . . . . . . . . . . . . . . .
Functions are first-class objects . . . . . . . . . . . . . . . . . . . . . . . . .
JSHint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
JavaScript versions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Handling callbacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Starting up
Install Node . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
NPM - Node Package Manager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Global vs. Local . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
NPM commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
npm ls [filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
npm install package[@filters . . . . . . . . . . . . . . . . . . . . . . . . . .
npm rm package_name[@version . . . . . . . . . . . . . . . . . . . . . . .
npm view [@ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Understanding
Understanding the Node event loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
An event-queue processing loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Callbacks that will generate events . . . . . . . . . . . . . . . . . . . . . . . . . . .
6
6
6
6
7
7
7
8
9
10
11
13
14
15
15
16
17
17
18
18
18
18
19
20
20
21
21
21
22
Plik z chomika:
nimtiz
Inne pliki z tego folderu:
[HTML][HTML5 Canvas. Graphics. Animation and Game Development].pdf
(29804 KB)
[CSS][CSS3 Foundations].pdf
(23466 KB)
[JAVASCRIPT][Professional AngularJS].pdf
(21169 KB)
[HTML][HTML5 Foundations].pdf
(32597 KB)
[JAVASCRIPT][Beginning JavaScript Charts].pdf
(19671 KB)
Inne foldery tego chomika:
Books
Fruity Loops
Prywatne
Virtual Machines
Workout Books
Zgłoś jeśli
naruszono regulamin