JacksonTian / diveintonode_examples

《深入浅出Node.js》的相关代码

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

《深入浅出NodeJS》2处问题反馈

lienhua34 opened this issue · comments

2016年3月河北第12次印刷版本。
有两处问题:

  1. 第98页中间的
{ 
    readConfig: function() {},
    ...
    complieAsserts: function() {}, 
    ...
}

中的compile单词写错了。
2. 第63页开头,原话是这样的

在具体实现上,process.nextTick()的回调函数保存在一个数组中,setImmediate()的结果则是保存在链表中。在行为上,process.nextTick()在每轮循环中会将数组中的回调函数全部执行完,而setImmediate()在每轮循环中执行链表中的一个回调函数。

我在我的环境(node 4.4.0)上验证了书中给出的示例,结果不对。最后两行的输出相反了。于是我查询了node的changelog,发现在"2015-01-14 version 1.0.1"的版本changelog中有下面这么一句话,

Updated setImmediate to process the full queue each turn of the event loop, instead of one per queue.

所以这个setImmediate()处理回调函数的机制应该已经变更了。

谢谢反馈。第一个问题下次印刷修复。第二个问题下次印刷加上注解,第二版会修复。