Skip to content

Commit

Permalink
doc: add missing parameter types
Browse files Browse the repository at this point in the history
Both of the `clearTimeout()` and `clearInterval()` functions in the
`timers` lib accepts the ID of the `Timeout` object returned by the
functions in a number or string type, e.g.

```js
const t = setTimeout(console.log, 5000, 'test');

clearTimeout(t[Symbol.toPrimitive]());
```

PR-URL: #39013
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
VoltrexKeyva authored and danielleadams committed Jun 15, 2021
1 parent c20e28e commit 858f66e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions doc/api/timers.md
Expand Up @@ -307,7 +307,8 @@ Cancels an `Immediate` object created by [`setImmediate()`][].
added: v0.0.1
-->

* `timeout` {Timeout} A `Timeout` object as returned by [`setInterval()`][].
* `timeout` {Timeout|string|number} A `Timeout` object as returned by [`setInterval()`][]
or the [primitive][] of the `Timeout` object as a string or a number.

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

Expand All @@ -316,7 +317,8 @@ Cancels a `Timeout` object created by [`setInterval()`][].
added: v0.0.1
-->

* `timeout` {Timeout} A `Timeout` object as returned by [`setTimeout()`][].
* `timeout` {Timeout|string|number} A `Timeout` object as returned by [`setTimeout()`][]
or the [primitive][] of the `Timeout` object as a string or a number.

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

Expand Down Expand Up @@ -478,3 +480,4 @@ const interval = 100;
[`setTimeout()`]: timers.md#timers_settimeout_callback_delay_args
[`util.promisify()`]: util.md#util_util_promisify_original
[`worker_threads`]: worker_threads.md
[primitive]: timers.md#timers_timeout_symbol_toprimitive

0 comments on commit 858f66e

Please sign in to comment.