More Related Content
Similar to All about NodeJS
Similar to All about NodeJS (20)
All about NodeJS
- 6. 什麼是NodeJS 舊瓶裝新酒 MozillaSpiderMonkey AptanaJaxer(http://jaxer.org/) couchDB (RESTful API) GoogleV8 v8cgi(http://code.google.com/p/v8cgi/) v8juice(http://code.google.com/p/v8-juice/) wikipedia: Comparison of server-side JavaScript solutions
- 50. 最簡單的程式範例helloworld伺服器 一頁就放的下的程式 var http = require('http'); http.createServer(function(req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello World.'); }).listen(1337, "127.0.0.1"); console.log('Server running at http://127.0.0.1:1337/');
- 65. Javascript背景知識事件與callback函數 在NodeJS環境中,有非常多的操作是用callback來完成,例如這一段mongo db的範例 varp_client = new Db('integration_tests_20', new Server("127.0.0.1", 27017, {}), {'pk':CustomPKFactory}); p_client.open(function(err, p_client) { p_client.dropDatabase(function(err, done) { p_client.createCollection('test_custom_key', function(err, collection) { collection.insert({'a':1}, function(err, docs) { collection.find({'_id':newObjectID("aaaaaaaaaaaa")}, function(err, cursor) { cursor.toArray(function(err, items) { test.assertEquals(1, items.length); p_client.close(); });});});});});});
- 96. 開發NodeJS程式Global Scope環境 結果可以看到: > (function(o){for(var i in o) console.log(i)})(this); ArrayBuffer Int8Array Uint8Array Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array DataView global …… TypedArray相關物件 Global物件的別名,就像瀏覽器環境中的window物件
- 97. 開發NodeJS程式Global Scope環境 結果可以看到: … process GLOBAL root Buffer setTimeout setInterval clearTimeout clearInterval console 處理行程的物件,有行程相關資訊、取得工作目錄等功能 Global物件的別名,就像瀏覽器環境中的window物件 用來處理binary資料的物件 跟瀏覽器中的一樣啦 用來做stdio的物件,可以輸出錯誤、debug、log等資訊
- 227. 一些資源 http://nodejs.org http://npmjs.org http://howtonode.org http://groups.google.com/group/nodejs http://www.facebook.com/NodeJS.tw http://wiki.nodejs.tw https://github.com/tjanczuk/iisnode