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: nodejs#39013
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Darshan Sen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
VoltrexKeyva authored and foxxyz committed Oct 18, 2021
1 parent 8df2479 commit c56928b
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 c56928b

Please sign in to comment.