{ "source": "doc/api/timers.markdown", "modules": [ { "textRaw": "Timers", "name": "timers", "stability": 3, "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": "clearImmediate(immediateObject)", "type": "method", "name": "clearImmediate", "desc": "

Stops an immediate from triggering.\n\n

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

Stops an interval from triggering.\n\n

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

Prevents a timeout from triggering.\n\n

\n", "signatures": [ { "params": [ { "name": "timeoutObject" } ] } ] }, { "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

Returns the timer.\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\nimmediateObject 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 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": "setInterval(callback, delay[, arg][, ...])", "type": "method", "name": "setInterval", "desc": "

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

\n

To follow browser behavior, when using delays larger than 2147483647\nmilliseconds (approximately 25 days) or less than 1, Node.js will use 1 as the\ndelay.\n\n

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

To schedule execution of a one-time callback after delay milliseconds. Returns a\ntimeoutObject 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

To follow browser behavior, when using delays larger than 2147483647\nmilliseconds (approximately 25 days) or less than 1, the timeout is executed\nimmediately, as if the delay was set to 1.\n\n

\n", "signatures": [ { "params": [ { "name": "callback" }, { "name": "delay" }, { "name": "arg", "optional": true }, { "name": "...", "optional": true } ] } ] }, { "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, it 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

Returns the timer.\n\n

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