Skip to content

Commit 797bd73

Browse files
VoltrexKeyvarichardlau
authored andcommitted
doc: add missing parameter types
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>
1 parent afb6178 commit 797bd73

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

doc/api/timers.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,8 @@ Cancels an `Immediate` object created by [`setImmediate()`][].
305305
added: v0.0.1
306306
-->
307307

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

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

@@ -314,7 +315,8 @@ Cancels a `Timeout` object created by [`setInterval()`][].
314315
added: v0.0.1
315316
-->
316317

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

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

@@ -329,3 +331,4 @@ Cancels a `Timeout` object created by [`setTimeout()`][].
329331
[`setTimeout()`]: timers.md#timers_settimeout_callback_delay_args
330332
[`util.promisify()`]: util.md#util_util_promisify_original
331333
[`worker_threads`]: worker_threads.md
334+
[primitive]: timers.md#timers_timeout_symbol_toprimitive

0 commit comments

Comments
 (0)