Hands-on Node.js

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

Author(s): Pedro Teixeira
Publisher: Lean Publishing
Year: 2013

Language: English
Pages: 142

Table of Contents......Page 4
Why the sudden, exponential popularity?......Page 12
Source code......Page 13
Where will this book lead you?......Page 14
Solution 1: Create more call stacks......Page 15
Solution 2: Use event-driven I/O......Page 16
Why JavaScript?......Page 17
How I Learned to Stop Fearing and Love JavaScript......Page 18
Function Declaration Styles......Page 19
Functions are first-class objects......Page 21
JSHint......Page 22
References......Page 23
Install Node......Page 24
An event-queue processing loop......Page 26
Don't block!......Page 27
Modules with complete or relative path......Page 29
Global vs. Local......Page 30
npm install package[@filters......Page 31
npm rm package_name[@version......Page 32
The Package.json Manifest......Page 33
console......Page 35
util......Page 36
Buffers......Page 38
Exercise 1......Page 39
Exercise 3......Page 40
.once......Page 41
Creating an Event Emitter......Page 42
Exercise 2......Page 43
clearTimeout......Page 44
setImmediate......Page 45
A note on tail recursion......Page 46
fs.stat and fs.fstat......Page 48
Open a file......Page 49
Write into a file......Page 50
Exercise 1 - get the size of a file......Page 51
Exercise 6 - change the content of a file......Page 52
HTTP Server......Page 53
req.headers......Page 54
Write a header......Page 55
Write a piece of the response body......Page 56
http.request()......Page 57
Exercise 4......Page 59
Know when it ends......Page 60
Write to it......Page 61
Filesystem streams......Page 62
The Slow Client Problem and Back-pressure......Page 63
What can we do?......Page 64
Pipe......Page 65
Write a string or a buffer......Page 66
Idle sockets......Page 67
server.close()......Page 68
TCP client......Page 69
Error handling......Page 70
Exercise 2......Page 71
Datagram server......Page 72
Datagram client......Page 73
Datagram Multicast......Page 74
Sending multicast messages......Page 75
Exercise 1......Page 76
Executing commands......Page 77
Spawning processes......Page 78
Exercise 1......Page 79
A streaming example......Page 80
Exercise 1......Page 81
Public key......Page 82
TLS Client......Page 83
Exercise 2......Page 84
Exercise 5......Page 85
HTTPS Client......Page 86
One file module......Page 88
An aggregating module......Page 89
A pseudo-class that inherits......Page 90
node_modules and npm bundle......Page 91
Bundling......Page 92
Node built-in debugger......Page 93
Node Inspector......Page 94
Live edit......Page 97
A test runner......Page 98
Assert truthfulness:......Page 100
equal (strict equality)......Page 101
assert typeof......Page 102
Putting it all together......Page 103
Callback flow......Page 106
The boomerang effect......Page 107
Parallel Iterations......Page 108
async.forEach......Page 109
async.map......Page 110
async.filter......Page 111
async.reject......Page 112
async.reduce......Page 113
async.detect......Page 114
async.every......Page 115
async.series......Page 116
async.parallel......Page 117
async.whilst......Page 118
async.waterfall......Page 119
async.queue......Page 120
One Solution:......Page 121
One Solution:......Page 122
Exercise 1 - get the size of a file......Page 123
One Solution:......Page 124
Exercise 4 - Overwrite a file......Page 125
One Solution:......Page 126
One Solution:......Page 127
One Solution:......Page 128
Exercise 3......Page 129
One Solution:......Page 130
One Solution:......Page 131
One Solution:......Page 133
One Solution:......Page 134
One Solution:......Page 135
One Solution:......Page 136
One Solution:......Page 139
One Solution:......Page 140
One Solution:......Page 141