Skip to content

Commit 0fd3327

Browse files
benglbenjamingr
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 <jasnell@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
1 parent f158a86 commit 0fd3327

File tree

1 file changed

+23
-18
lines changed

1 file changed

+23
-18
lines changed

doc/api/timers.markdown

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,43 +7,44 @@ 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
If `callback` is not a function `setImmediate()` will throw immediately.
4142

4243
## setInterval(callback, delay[, arg][, ...])
4344

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

4849
To follow browser behavior, when using delays larger than 2147483647
4950
milliseconds (approximately 25 days) or less than 1, Node.js will use 1 as the
@@ -54,8 +55,8 @@ If `callback` is not a function `setInterval()` will throw immediately.
5455
## setTimeout(callback, delay[, arg][, ...])
5556

5657
To schedule execution of a one-time `callback` after `delay` milliseconds.
57-
Returns a `timeoutObject` for possible use with `clearTimeout()`. Optionally you
58-
can also pass arguments to the callback.
58+
Returns a `timeoutObject` for possible use with [`clearTimeout`][]. Additional
59+
optional arguments may be passed to the callback.
5960

6061
The callback will likely not be invoked in precisely `delay` milliseconds.
6162
Node.js makes no guarantees about the exact timing of when callbacks will fire,
@@ -71,16 +72,20 @@ If `callback` is not a function `setTimeout()` will throw immediately.
7172
## unref()
7273

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

79-
In the case of `setTimeout` when you `unref` you create a separate timer that
80-
will wakeup the event loop, creating too many of these may adversely effect
81-
event loop performance -- use wisely.
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.
8283

8384
Returns the timer.
8485

86+
[`clearImmediate`]: timers.html#timers_clearimmediate_immediateobject
87+
[`clearInterval`]: timers.html#timers_clearinterval_intervalobject
88+
[`clearTimeout`]: timers.html#timers_cleartimeout_timeoutobject
89+
[`setImmediate`]: timers.html#timers_setimmediate_callback_arg
8590
[`setInterval`]: timers.html#timers_setinterval_callback_delay_arg
8691
[`setTimeout`]: timers.html#timers_settimeout_callback_delay_arg

0 commit comments

Comments
 (0)