55All of the timer functions are globals. You do not need to ` require() `
66this module in order to use them.
77
8- ## clearImmediate(immediateObject)
8+ ## Class: Immediate
99
10- Stops an ` immediateObject ` , as created by [ ` setImmediate ` ] [ ] , from triggering.
10+ This object is created internally and is returned from [ ` setImmediate ` ] [ ] . It
11+ can be passed to [ ` clearImmediate ` ] in order to cancel the scheduled actions.
1112
12- ## clearInterval(intervalObject)
13+ ## Class: Timeout
1314
14- Stops an ` intervalObject ` , as created by [ ` setInterval ` ] [ ] , from triggering.
15+ This object is created internally and is returned from [ ` setTimeout ` ] [ ] and
16+ [ ` setInterval ` ] [ ] . It can be passed to [ ` clearTimeout ` ] [ ] or [ ` clearInterval ` ] [ ]
17+ respectively in order to cancel the scheduled actions.
1518
16- ## clearTimeout(timeoutObject )
19+ ### ref( )
1720
18- Prevents a ` timeoutObject ` , as created by [ ` setTimeout ` ] [ ] , from triggering.
21+ If a ` Timeout ` was previously ` unref() ` d, then ` ref() ` can be called to
22+ explicitly request the ` Timeout ` hold the program open. If the ` Timeout ` is
23+ already ` ref ` d calling ` ref ` again will have no effect.
1924
20- ## ref()
25+ Returns the ` Timeout ` .
2126
22- If a timer was previously ` unref() ` d, then ` ref() ` can be called to explicitly
23- request the timer hold the program open. If the timer is already ` ref ` d calling
24- ` ref ` again will have no effect.
27+ ### unref()
2528
26- Returns the timer.
29+ The ` Timeout ` returned by [ ` setTimeout ` ] [ ] and [ ` setInterval ` ] [ ] also has the
30+ method ` timeout.unref() ` which allows the creation of a ` Timeout ` that is active
31+ but if it is the only item left in the event loop, it won't keep the program
32+ running. If the ` Timeout ` is already ` unref ` d calling ` unref ` again will have no
33+ effect.
34+
35+ In the case of [ ` setTimeout ` ] [ ] , ` unref ` creates a separate underlying timer
36+ handle that will wakeup the event loop, creating too many of these may adversely
37+ effect event loop performance -- use wisely.
38+
39+ Returns the ` Timeout ` .
40+
41+ ## clearImmediate(immediate)
42+
43+ Stops an ` Immediate ` , as created by [ ` setImmediate ` ] [ ] , from triggering.
44+
45+ ## clearInterval(timeout)
46+
47+ Stops a ` Timeout ` , as created by [ ` setInterval ` ] [ ] , from triggering.
48+
49+ ## clearTimeout(timeout)
50+
51+ Stops a ` Timeout ` , as created by [ ` setTimeout ` ] [ ] , from triggering.
2752
2853## setImmediate(callback[ , arg] [ , ... ] )
2954
3055Schedules "immediate" execution of ` callback ` after I/O events'
31- callbacks and before timers set by [ ` setTimeout ` ] [ ] and [ ` setInterval ` ] [ ] are
32- triggered. Returns an ` immediateObject ` for possible use with
56+ callbacks and before timers ( ` Timeout ` s) set by [ ` setTimeout ` ] [ ] and
57+ [ ` setInterval ` ] [ ] are triggered. Returns an ` Immediate ` for possible use with
3358[ ` clearImmediate ` ] [ ] . Additional optional arguments may be passed to the
3459callback.
3560
@@ -43,7 +68,7 @@ If `callback` is not a function `setImmediate()` will throw immediately.
4368## setInterval(callback, delay[ , arg] [ , ... ] )
4469
4570Schedules repeated execution of ` callback ` every ` delay ` milliseconds.
46- Returns a ` intervalObject ` for possible use with [ ` clearInterval ` ] [ ] . Additional
71+ Returns a ` Timeout ` for possible use with [ ` clearInterval ` ] [ ] . Additional
4772optional arguments may be passed to the callback.
4873
4974To follow browser behavior, when using delays larger than 2147483647
@@ -55,7 +80,7 @@ If `callback` is not a function `setInterval()` will throw immediately.
5580## setTimeout(callback, delay[ , arg] [ , ... ] )
5681
5782Schedules execution of a one-time ` callback ` after ` delay ` milliseconds.
58- Returns a ` timeoutObject ` for possible use with [ ` clearTimeout ` ] [ ] . Additional
83+ Returns a ` Timeout ` for possible use with [ ` clearTimeout ` ] [ ] . Additional
5984optional arguments may be passed to the callback.
6085
6186The callback will likely not be invoked in precisely ` delay ` milliseconds.
@@ -69,20 +94,6 @@ immediately, as if the `delay` was set to 1.
6994
7095If ` callback ` is not a function ` setTimeout() ` will throw immediately.
7196
72- ## unref()
73-
74- The opaque value returned by [ ` setTimeout ` ] [ ] and [ ` setInterval ` ] [ ] also has the
75- method ` timer.unref() ` which allows the creation of a timer that is active but
76- if it is the only item left in the event loop, it won't keep the program
77- running. If the timer is already ` unref ` d calling ` unref ` again will have no
78- effect.
79-
80- In the case of [ ` setTimeout ` ] [ ] , ` unref ` creates a separate timer that will
81- wakeup the event loop, creating too many of these may adversely effect event
82- loop performance -- use wisely.
83-
84- Returns the timer.
85-
8697[ `clearImmediate` ] : timers.html#timers_clearimmediate_immediateobject
8798[ `clearInterval` ] : timers.html#timers_clearinterval_intervalobject
8899[ `clearTimeout` ] : timers.html#timers_cleartimeout_timeoutobject
0 commit comments