node_timers - msforest/notebook GitHub Wiki
模拟与浏览器等同功能的定时器(setTimeout/setInterval)
预习概念
node vs browser
- setTimeout 函数里的 this 意义不同,浏览器指代全局变量 window,node 指代 Timeout 对象
- timer 参数不接受字符串,若为字符串,则抛错;
Timeout(由 setTimeout 和 setInterval 返回)
- hasRef
- ref
- refresh
- unref
Immediate(node.js 独有,由 SetImmediate 返回)
- hasRef
- ref
- unref
对于 clearImmediate / clearTimeout / clearInterval 是可以混用的,都达到取消的功能