类:Timeout
【Class: Timeout】
此对象在内部创建,并从 setTimeout() 和 setInterval() 返回。它可以传递给 clearTimeout() 或 clearInterval(),以取消已安排的操作。
【This object is created internally and is returned from setTimeout() and
setInterval(). It can be passed to either clearTimeout() or
clearInterval() in order to cancel the scheduled actions.】
默认情况下,当使用 setTimeout() 或 setInterval() 调度计时器时,只要计时器处于活动状态,Node.js 事件循环将继续运行。这些函数返回的每个 Timeout 对象都导出了 timeout.ref() 和 timeout.unref() 函数,可用于控制此默认行为。
【By default, when a timer is scheduled using either setTimeout() or
setInterval(), the Node.js event loop will continue running as long as the
timer is active. Each of the Timeout objects returned by these functions
export both timeout.ref() and timeout.unref() functions that can be used to
control this default behavior.】