1. Introduce Platform
Node.js is not JS, it is platform based on V8 C++.
Node.js is event driven, callback. Net modules including HTTP, DNS, NET, UDP, HTTPS, TLS.
Node.js is single thread, sing process.
a. call the inner properties in inner functions
b, keep all the properties in memory
2. What I installed on my Machine
>node -v
v0.10.28 >$ npm -v 1.4.10
Check the version of some mdules
>npm info express version
4.3.0
3. Module Strategy
var circle = require('./sillycat-aes/app/index');
console.log(circle.area(4));
var PI = Math.PI;
exports.area = function(r) {
return PI * r * r;
};
exports.circumference = function(r){
return 2*PI *r;
};
main in the package.json configuration.
4. Multiple Events in the same Time
api.getUser(“username”, function(profile) {
//got the profile
});
api.getTimeline(“username”, function(timeline){});
api.getSkin(“username”, function(skin){});
A plugin to fix the callback order/full problems
https://github.com/JacksonTian/eventproxy
6. Buffer
var rs = fs.createReadStream(’testdata.md’, {encoding:’utf-8’, bufferSize:11});
data = data + trunk; ——> data = data.toString() + trunk.toString();