Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: add added: information for timers #7493

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions doc/api/timers.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ export both `timeout.ref()` and `timeout.unref()` functions that can be used to
control this default behavior.

### timeout.ref()
<!-- YAML
added: v0.9.1
-->

When called, requests that the Node.js event loop *not* exit so long as the
`Timeout` is active. Calling `timeout.ref()` multiple times will have no effect.
Expand All @@ -40,6 +43,9 @@ previously.
Returns a reference to the `Timeout`.

### timeout.unref()
<!-- YAML
added: v0.9.1
-->

When called, the active `Timeout` object will not require the Node.js event loop
to remain active. If there is no other activity keeping the event loop running,
Expand All @@ -60,6 +66,9 @@ which method was used to create the timer and what other work the Node.js
event loop is doing.

### setImmediate(callback[, ...arg])
<!-- YAML
added: v0.9.1
-->

* `callback` {Function} The function to call at the end of this turn of
[the Node.js Event Loop]
Expand All @@ -79,6 +88,9 @@ next event loop iteration.
If `callback` is not a function, a [`TypeError`][] will be thrown.

### setInterval(callback, delay[, ...arg])
<!-- YAML
added: v0.0.1
-->

* `callback` {Function} The function to call when the timer elapses.
* `delay` {number} The number of milliseconds to wait before calling the
Expand All @@ -94,6 +106,9 @@ set to `1`.
If `callback` is not a function, a [`TypeError`][] will be thrown.

### setTimeout(callback, delay[, ...arg])
<!-- YAML
added: v0.0.1
Copy link
Contributor

@Fishrock123 Fishrock123 Jun 30, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't seem quite right?

I'm pretty sure Isaac added these but that wasn't at the start I think...

The oldest reference I seem to be able to find of it exposed on the global (actually GLOBAL at the time) is 7a2e784 (v0.1.16)

hmmm, Indeed it looks like the original was added before v0.0.1 but I'm not sure it was exposed in a way that uh, counts?

.. also note that (awkwardly) these were actually added to the timers module pretty long after they were available on the global object. They were added to the module in 7994400 (v0.3.1)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The oldest reference I seem to be able to find of it exposed on the global (actually GLOBAL at the time) is 7a2e784 (v0.1.16)

It was present on the global before; the JS entry point (src/node.js) is executed without the function wrapper, so the functions defined there became part of the global scope.

If you prefer, I can go for the version in which they were added to the timers module, but that’s not the common usage pattern (not that it really matters too much for this old stuff anyway).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

¯_(ツ)_/¯

-->

* `callback` {Function} The function to call when the timer elapses.
* `delay` {number} The number of milliseconds to wait before calling the
Expand All @@ -120,19 +135,28 @@ each return objects that represent the scheduled timers. These can be used to
cancel the timer and prevent it from triggering.

### clearImmediate(immediate)
<!-- YAML
added: v0.9.1
-->

* `immediate` {Immediate} An `Immediate` object as returned by
[`setImmediate()`][].

Cancels an `Immediate` object created by [`setImmediate()`][].

### clearInterval(timeout)
<!-- YAML
added: v0.0.1
-->

* `timeout` {Timeout} A `Timeout` object as returned by [`setInterval()`][].

Cancels a `Timeout` object created by [`setInterval()`][].

### clearTimeout(timeout)
<!-- YAML
added: v0.0.1
-->

* `timeout` {Timeout} A `Timeout` object as returned by [`setTimeout()`][].

Expand Down