{ "source": "doc/api/timers.markdown", "modules": [ { "textRaw": "Timers", "name": "timers", "stability": 5, "stabilityText": "Locked", "desc": "

All of the timer functions are globals. You do not need to require()\nthis module in order to use them.\n\n

\n", "methods": [ { "textRaw": "setTimeout(callback, delay, [arg], [...])", "type": "method", "name": "setTimeout", "desc": "

To schedule execution of a one-time callback after delay milliseconds. Returns a\ntimeoutId for possible use with clearTimeout(). Optionally you can\nalso pass arguments to the callback.\n\n

\n

It is important to note that your callback will probably not be called in exactly\ndelay milliseconds - Node.js makes no guarantees about the exact timing of when\nthe callback will fire, nor of the ordering things will fire in. The callback will\nbe called as close as possible to the time specified.\n\n

\n", "signatures": [ { "params": [ { "name": "callback" }, { "name": "delay" }, { "name": "arg", "optional": true }, { "name": "...", "optional": true } ] } ] }, { "textRaw": "clearTimeout(timeoutId)", "type": "method", "name": "clearTimeout", "desc": "

Prevents a timeout from triggering.\n\n

\n", "signatures": [ { "params": [ { "name": "timeoutId" } ] } ] }, { "textRaw": "setInterval(callback, delay, [arg], [...])", "type": "method", "name": "setInterval", "desc": "

To schedule the repeated execution of callback every delay milliseconds.\nReturns a intervalId for possible use with clearInterval(). Optionally\nyou can also pass arguments to the callback.\n\n

\n", "signatures": [ { "params": [ { "name": "callback" }, { "name": "delay" }, { "name": "arg", "optional": true }, { "name": "...", "optional": true } ] } ] }, { "textRaw": "clearInterval(intervalId)", "type": "method", "name": "clearInterval", "desc": "

Stops a interval from triggering.\n\n

\n", "signatures": [ { "params": [ { "name": "intervalId" } ] } ] }, { "textRaw": "unref()", "type": "method", "name": "unref", "desc": "

The opaque value returned by setTimeout and setInterval also has the method\ntimer.unref() which will allow you to create a timer that is active but if\nit is the only item left in the event loop won't keep the program running.\nIf the timer is already unrefd calling unref again will have no effect.\n\n

\n

In the case of setTimeout when you unref you create a separate timer that\nwill wakeup the event loop, creating too many of these may adversely effect\nevent loop performance -- use wisely.\n\n

\n", "signatures": [ { "params": [] } ] }, { "textRaw": "ref()", "type": "method", "name": "ref", "desc": "

If you had previously unref()d a timer you can call ref() to explicitly\nrequest the timer hold the program open. If the timer is already refd calling\nref again will have no effect.\n\n

\n", "signatures": [ { "params": [] } ] }, { "textRaw": "setImmediate(callback, [arg], [...])", "type": "method", "name": "setImmediate", "desc": "

To schedule the "immediate" execution of callback after I/O events\ncallbacks and before setTimeout and setInterval . Returns an\nimmediateId for possible use with clearImmediate(). Optionally you\ncan also pass arguments to the callback.\n\n

\n

Callbacks for immediates are queued in the order in which they were created.\nThe entire callback queue is processed every event loop iteration. If you queue\nan immediate from a inside an executing callback that immediate won't fire\nuntil the next event loop iteration.\n\n

\n", "signatures": [ { "params": [ { "name": "callback" }, { "name": "arg", "optional": true }, { "name": "...", "optional": true } ] } ] }, { "textRaw": "clearImmediate(immediateId)", "type": "method", "name": "clearImmediate", "desc": "

Stops an immediate from triggering.\n

\n", "signatures": [ { "params": [ { "name": "immediateId" } ] } ] } ], "type": "module", "displayName": "Timers" } ] }