Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Introduction to Node and its Core Modules
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
aryoung
February 06, 2013
Programming
300
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Introduction to Node and its Core Modules
From
http://bathcamp.org/
, February 6th 2013
aryoung
February 06, 2013
More Decks by aryoung
See All by aryoung
Vim and the Web
aryoung
0
7.8k
Tern for Vim
aryoung
2
1.7k
Vim London: Custom Motions
aryoung
6
3.8k
Other Decks in Programming
See All in Programming
AIとASP.NET Coreで雑Webアプリを作った話
mayuki
0
660
Honoでのサプライチェーン侵害対策 〜 3つのライブラリに学ぶ
yusukebe
6
1.3k
PHPで使える日時の表現と、その知り方 #frontend_phpcon_do
o0h
PRO
0
260
決定論的オーケストレーションの設計と実装 / Design and Implementation of Deterministic Orchestration
nrslib
4
1.4k
Webフレームワークの ベンチマークについて
yusukebe
0
170
[2026年度第1回ORセミナー] 計画最適化ベンチャーと競技プログラミング人材
terryu16
0
270
Hunting Vulnerabilities in Symfony with LLMs
vinceamstoutz
0
550
Inside Stream API
skrb
1
740
CSC307 Lecture 17
javiergs
PRO
0
320
ユニットテストの先へ:テスト技法で要求・仕様を整理するJava開発実践 / Beyond_Unit_Testing_Practical_Java_Development_Techniques_for_Organizing_Requirements_and_Specifications
shimashima35
0
410
コンテキストの使い捨てをやめる — ビジネスルール駆動開発と miko —
ioki
0
210
代数的データ型って何が嬉しいの? #frontend_phpcon_do
kajitack
8
3.7k
Featured
See All Featured
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
440
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
370
The World Runs on Bad Software
bkeepers
PRO
72
12k
Un-Boring Meetings
codingconduct
0
320
BBQ
matthewcrist
89
10k
Leo the Paperboy
mayatellez
7
1.8k
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
560
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
590
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
240
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
270
Practical Orchestrator
shlominoach
191
11k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Transcript
Introduction to Node Alex
Overview ‣ Brief
5 Years Ago... ‣ We
Thursday, 7 February 13
A
Node’s Strengths ‣ Network-oriented
Installation ‣ Wizards
Runtime Environment ‣ Every
Modules ‣ CommonJS
Core Modules ‣ Events,
"Node's
Why Bother? ‣ Events/streams
Streams var zlib = require('zlib').createGzip(); var fs = require('fs'); var
inp = fs.createReadStream('input.txt'); var out = fs.createWriteStream('output.txt.gz'); inp.pipe(gzip).pipe(out); Clean,
Events var util = require('util'); var events = require('events'); function
Player() { events.EventEmitter.call(this); } util.inherits(Player, events.EventEmitter); var player = new Player(); player.on('play', function(track) { console.log('[NP]:', track.title); }); player.emit('play', { title: 'Spit On A Stranger', artist: 'Pavement' }); Thursday, 7 February 13
Servers var net = require('net'); var server = net.createServer(function(c) {
console.log('server connected'); c.on('end', function() { console.log('server disconnected'); }); c.write('hello\r\n'); c.pipe(c); }); server.listen(8124, function() { //'listening' listener console.log('server bound'); }); Thursday, 7 February 13
HTTP Server var http = require('http'); var fs = require('fs');
http.createServer(function(req, res) { fs.readFile(__dirname + 'index.html', function(err, data) { if (err) { res.statusCode = 500; res.end(String(err)); } else { res.end(data); } }); }).listen(8000); Thursday, 7 February 13
HTTP Server var http = require('http'); var fs = require('fs');
http.createServer(function(req, res) { fs.readFile(__dirname + 'index.html', function(err, data) { if (err) { res.statusCode = 500; res.end(String(err)); } else { res.end(data); } }); }).listen(8000); Thursday, 7 February 13
HTTP Server var http = require('http'); var fs = require('fs');
http.createServer(function(req, res) { fs.readFile(__dirname + 'index.html', function(err, data) { if (err) { res.statusCode = 500; res.end(String(err)); } else { res.end(data); } }); }).listen(8000); Thursday, 7 February 13
HTTP Server var http = require('http'); var fs = require('fs');
http.createServer(function(req, res) { fs.readFile(__dirname + 'index.html', function(err, data) { if (err) { res.statusCode = 500; res.end(String(err)); } else { res.end(data); } }); }).listen(8000); Not
Streams with HTTP var http = require('http'); var fs =
require('fs'); http.createServer(function(req, res) { var stream = fs.createReadStream('index.html'); stream.pipe(res); }).listen(8000); Thursday, 7 February 13
Gzip for Free var http = require('http'); var fs =
require('fs'); var zlib = require('zlib'); http.createServer(function(req, res) { var stream = fs.createReadStream('index.html'); res.writeHead(200, { 'content-encoding': 'gzip' }); stream.pipe(zlib.createGzip()).pipe(res); }).listen(8000); Thursday, 7 February 13
Gzip for Free var http = require('http'); var fs =
require('fs'); var zlib = require('zlib'); http.createServer(function(req, res) { var stream = fs.createReadStream('index.html'); res.writeHead(200, { 'content-encoding': 'gzip' }); stream.pipe(zlib.createGzip()).pipe(res); }).listen(8000); How
TO-DO: Learn
The End http://www.flickr.com/photos/dunechaser/6884829633/ Thursday, 7 February 13