NODEJS(8)Book Read - Nodejs_InfoQ.pdf

本文介绍了Node.js的基础知识,包括其作为基于V8引擎的平台特性、事件驱动的架构及核心模块如HTTP、DNS等。同时探讨了单线程模型、内存管理方式以及异步IO机制,并通过实例展示了模块加载策略。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

NODEJS(8)Book Read - Nodejs_InfoQ.pdf

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.

Javascript Closure
function(response) {
     var responseHTML = “”;
     response.on(‘data’, function (chunk) {
          responseHTML = responseHTML + chunk;  
     });
     response.on(‘end’, function() {
          console.log(responseHTML);
     }
}

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

5. Async
Check Status : read, select, poll, epoll, select, kqueue

Linux System provide AIO as async IO.

Node.js ——> libUV ——> linux (libev, libeio)

6. Buffer
var rs = fs.createReadStream(’testdata.md’, {encoding:’utf-8’, bufferSize:11});
data = data + trunk;  ——> data = data.toString() + trunk.toString();

>npm info bufferhelper version


References:
Node.js_InfoQ.pdf
http://www.ruanyifeng.com/blog/2009/08/learning_javascript_closures.html
https://github.com/JacksonTian/eventproxy

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值