From c56928b2f5525c0b738e63c49071f412bdc6a7b7 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 71079343db3aad..ed200f3c36e701 100644 --- a/doc/api/timers.md +++ b/doc/api/timers.md @@ -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()`][]. @@ -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()`][]. @@ -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