Skip to content

Commit f53cc37

Browse files
benglFishrock123
authored andcommitted
doc: grammar, clarity and links in timers doc
Added appropriate in-document links. Clarified a bit of `setImmediate`, including a quick grammar fix (plural possessive apostrophe). PR-URL: #5792 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]>
1 parent 15c7b3a commit f53cc37

File tree

1 file changed

+23
-18
lines changed

1 file changed

+23
-18
lines changed

doc/api/timers.markdown

+23-18
Original file line numberDiff line numberDiff line change
@@ -7,41 +7,42 @@ this module in order to use them.
77

88
## clearImmediate(immediateObject)
99

10-
Stops an immediate from triggering.
10+
Stops an `immediateObject`, as created by [`setImmediate`][], from triggering.
1111

1212
## clearInterval(intervalObject)
1313

14-
Stops an interval from triggering.
14+
Stops an `intervalObject`, as created by [`setInterval`][], from triggering.
1515

1616
## clearTimeout(timeoutObject)
1717

18-
Prevents a timeout from triggering.
18+
Prevents a `timeoutObject`, as created by [`setTimeout`][], from triggering.
1919

2020
## ref()
2121

22-
If you had previously `unref()`d a timer you can call `ref()` to explicitly
22+
If a timer was previously `unref()`d, then `ref()` can be called to explicitly
2323
request the timer hold the program open. If the timer is already `ref`d calling
2424
`ref` again will have no effect.
2525

2626
Returns the timer.
2727

2828
## setImmediate(callback[, arg][, ...])
2929

30-
To schedule the "immediate" execution of `callback` after I/O events
31-
callbacks and before [`setTimeout`][] and [`setInterval`][]. Returns an
32-
`immediateObject` for possible use with `clearImmediate()`. Optionally you
33-
can also pass arguments to the callback.
30+
To schedule the "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
33+
[`clearImmediate`][]. Additional optional arguments may be passed to the
34+
callback.
3435

3536
Callbacks for immediates are queued in the order in which they were created.
36-
The entire callback queue is processed every event loop iteration. If you queue
37-
an immediate from inside an executing callback, that immediate won't fire
37+
The entire callback queue is processed every event loop iteration. If an
38+
immediate is queued from inside an executing callback, that immediate won't fire
3839
until the next event loop iteration.
3940

4041
## setInterval(callback, delay[, arg][, ...])
4142

4243
To schedule the repeated execution of `callback` every `delay` milliseconds.
43-
Returns a `intervalObject` for possible use with `clearInterval()`. Optionally
44-
you can also pass arguments to the callback.
44+
Returns a `intervalObject` for possible use with [`clearInterval`][]. Additional
45+
optional arguments may be passed to the callback.
4546

4647
To follow browser behavior, when using delays larger than 2147483647
4748
milliseconds (approximately 25 days) or less than 1, Node.js will use 1 as the
@@ -50,8 +51,8 @@ milliseconds (approximately 25 days) or less than 1, Node.js will use 1 as the
5051
## setTimeout(callback, delay[, arg][, ...])
5152

5253
To schedule execution of a one-time `callback` after `delay` milliseconds.
53-
Returns a `timeoutObject` for possible use with `clearTimeout()`. Optionally you
54-
can also pass arguments to the callback.
54+
Returns a `timeoutObject` for possible use with [`clearTimeout`][]. Additional
55+
optional arguments may be passed to the callback.
5556

5657
The callback will likely not be invoked in precisely `delay` milliseconds.
5758
Node.js makes no guarantees about the exact timing of when callbacks will fire,
@@ -65,16 +66,20 @@ immediately, as if the `delay` was set to 1.
6566
## unref()
6667

6768
The opaque value returned by [`setTimeout`][] and [`setInterval`][] also has the
68-
method `timer.unref()` which will allow you to create a timer that is active but
69+
method `timer.unref()` which allows the creation of a timer that is active but
6970
if it is the only item left in the event loop, it won't keep the program
7071
running. If the timer is already `unref`d calling `unref` again will have no
7172
effect.
7273

73-
In the case of `setTimeout` when you `unref` you create a separate timer that
74-
will wakeup the event loop, creating too many of these may adversely effect
75-
event loop performance -- use wisely.
74+
In the case of [`setTimeout`][], `unref` creates a separate timer that will
75+
wakeup the event loop, creating too many of these may adversely effect event
76+
loop performance -- use wisely.
7677

7778
Returns the timer.
7879

80+
[`clearImmediate`]: timers.html#timers_clearimmediate_immediateobject
81+
[`clearInterval`]: timers.html#timers_clearinterval_intervalobject
82+
[`clearTimeout`]: timers.html#timers_cleartimeout_timeoutobject
83+
[`setImmediate`]: timers.html#timers_setimmediate_callback_arg
7984
[`setInterval`]: timers.html#timers_setinterval_callback_delay_arg
8085
[`setTimeout`]: timers.html#timers_settimeout_callback_delay_arg

0 commit comments

Comments
 (0)