From 858f66e691be7ce11124a49b387f187c3b61640a Mon Sep 17 00:00:00 2001 From: Voltrex Date: Sat, 12 Jun 2021 16:50:55 +0430 Subject: [PATCH] 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: https://github.com/nodejs/node/pull/39013 Reviewed-By: Luigi Pinca Reviewed-By: Benjamin Gruenbaum Reviewed-By: Darshan Sen Reviewed-By: James M Snell --- doc/api/timers.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/doc/api/timers.md b/doc/api/timers.md index 8f6144e9445478..820e6a282aeb01 100644 --- a/doc/api/timers.md +++ b/doc/api/timers.md @@ -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()`][]. @@ -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()`][]. @@ -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