稳定性: 2 - 稳定

源代码: lib/timers.js

timer 模块开放了一个全局的 API,用于安排函数在未来某个时间点被调用。 因为定时器函数是全局的,所以使用 API 不需要调用 require('timers')

Node.js 中的定时器函数实现了与 Web 浏览器提供的定时器 API 类似的 API,但是使用了不同的内部实现(构建于 Node.js 事件循环)。

Stability: 2 - Stable

Source Code: lib/timers.js

The timer module exposes a global API for scheduling functions to be called at some future period of time. Because the timer functions are globals, there is no need to call require('timers') to use the API.

The timer functions within Node.js implement a similar API as the timers API provided by Web Browsers but use a different internal implementation that is built around the Node.js Event Loop.