Skip to content

Commit

Permalink
doc: consolidate timers docs in timers.markdown
Browse files Browse the repository at this point in the history
Rather than attempting to keep two versions of docs for timers up to
date, keep them in timers.markdown, and leave references to them in
globals.markdown.

Add setImmediate and clearImmediate to globals.markdown.

Change "To schedule" to "Schedules" in timers.markdown.

PR-URL: #5837
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Jeremiah Senkpiel <[email protected]>
Reviewed-By: Claudio Rodriguez <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
  • Loading branch information
bengl authored and Myles Borins committed Apr 5, 2016
1 parent a40b0cb commit 8bec8aa
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 27 deletions.
51 changes: 27 additions & 24 deletions doc/api/globals.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,23 @@ console.log(__filename);

`__filename` isn't actually a global but rather local to each module.

## clearInterval(t)
## clearImmediate(immediateObject)

Stop a timer that was previously created with [`setInterval()`][]. The callback
will not execute.
<!--type=global-->

[`clearImmediate`] is described in the [timers][] section.

## clearInterval(intervalObject)

<!--type=global-->

The timer functions are global variables. See the [timers][] section.
[`clearInterval`] is described in the [timers][] section.

## clearTimeout(t)
## clearTimeout(timeoutObject)

<!--type=global-->

Stop a timer that was previously created with [`setTimeout()`][]. The callback will
not execute.
[`clearTimeout`] is described in the [timers][] section.

## console

Expand Down Expand Up @@ -162,34 +166,33 @@ left untouched.
Use the internal `require()` machinery to look up the location of a module,
but rather than loading the module, just return the resolved filename.

## setInterval(cb, ms)
## setImmediate(callback[, arg][, ...])

Run callback `cb` repeatedly every `ms` milliseconds. Note that the actual
interval may vary, depending on external factors like OS timer granularity and
system load. It's never less than `ms` but it may be longer.
<!-- type=global -->

[`setImmediate`] is described in the [timers][] section.

The interval must be in the range of 1-2,147,483,647 inclusive. If the value is
outside that range, it's changed to 1 millisecond. Broadly speaking, a timer
cannot span more than 24.8 days.
## setInterval(callback, delay[, arg][, ...])

Returns an opaque value that represents the timer.
<!-- type=global -->

## setTimeout(cb, ms)
[`setInterval`] is described in the [timers][] section.

Run callback `cb` after *at least* `ms` milliseconds. The actual delay depends
on external factors like OS timer granularity and system load.
## setTimeout(callback, delay[, arg][, ...])

The timeout must be in the range of 1-2,147,483,647 inclusive. If the value is
outside that range, it's changed to 1 millisecond. Broadly speaking, a timer
cannot span more than 24.8 days.
<!-- type=global -->

Returns an opaque value that represents the timer.
[`setTimeout`] is described in the [timers][] section.

[`console`]: console.html
[`process` object]: process.html#process_process
[`setInterval()`]: #globals_setinterval_cb_ms
[`setTimeout()`]: #globals_settimeout_cb_ms
[buffer section]: buffer.html
[module system documentation]: modules.html
[Modules]: modules.html#modules_modules
[timers]: timers.html
[`clearImmediate`]: timers.html#timers_clearimmediate_immediateobject
[`clearInterval`]: timers.html#timers_clearinterval_intervalobject
[`clearTimeout`]: timers.html#timers_cleartimeout_timeoutobject
[`setImmediate`]: timers.html#timers_setimmediate_callback_arg
[`setInterval`]: timers.html#timers_setinterval_callback_delay_arg
[`setTimeout`]: timers.html#timers_settimeout_callback_delay_arg
6 changes: 3 additions & 3 deletions doc/api/timers.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Returns the timer.

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

To schedule the "immediate" execution of `callback` after I/O events'
Schedules "immediate" execution of `callback` after I/O events'
callbacks and before timers set by [`setTimeout`][] and [`setInterval`][] are
triggered. Returns an `immediateObject` for possible use with
[`clearImmediate`][]. Additional optional arguments may be passed to the
Expand All @@ -40,7 +40,7 @@ until the next event loop iteration.

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

To schedule the repeated execution of `callback` every `delay` milliseconds.
Schedules repeated execution of `callback` every `delay` milliseconds.
Returns a `intervalObject` for possible use with [`clearInterval`][]. Additional
optional arguments may be passed to the callback.

Expand All @@ -50,7 +50,7 @@ milliseconds (approximately 25 days) or less than 1, Node.js will use 1 as the

## setTimeout(callback, delay[, arg][, ...])

To schedule execution of a one-time `callback` after `delay` milliseconds.
Schedules execution of a one-time `callback` after `delay` milliseconds.
Returns a `timeoutObject` for possible use with [`clearTimeout`][]. Additional
optional arguments may be passed to the callback.

Expand Down

0 comments on commit 8bec8aa

Please sign in to comment.