Skip to content

Commit 858f66e

Browse files
VoltrexKeyvadanielleadams
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 c20e28e commit 858f66e

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
@@ -307,7 +307,8 @@ Cancels an `Immediate` object created by [`setImmediate()`][].
307307
added: v0.0.1
308308
-->
309309

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

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

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

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

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

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

0 commit comments

Comments
 (0)