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 richardlau committed Jul 20, 2021
1 parent afb6178 commit 797bd73
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions doc/api/timers.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,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 @@ -314,7 +315,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 All @@ -329,3 +331,4 @@ Cancels a `Timeout` object created by [`setTimeout()`][].
[`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 797bd73

Please sign in to comment.