From b37567525815f61c795ffe4c030a8b2ed501bc27 Mon Sep 17 00:00:00 2001 From: Voltrex Date: Sat, 12 Jun 2021 16:50:55 +0430 Subject: [PATCH 1/2] 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]()); ``` --- doc/api/timers.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/api/timers.md b/doc/api/timers.md index 8f6144e9445478..9181af08396e0a 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 ID 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 ID of the `Timeout` object as a string or a number. Cancels a `Timeout` object created by [`setTimeout()`][]. From 73032bcf813642e854e3b1c3025acb223a880f19 Mon Sep 17 00:00:00 2001 From: Voltrex Date: Sun, 13 Jun 2021 02:11:40 +0430 Subject: [PATCH 2/2] fixup! doc: add missing parameter types Change "ID" to "primitive" and reference `timeout[Symbol.toPrimitive]()` with a hyperlink. --- doc/api/timers.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/api/timers.md b/doc/api/timers.md index 9181af08396e0a..820e6a282aeb01 100644 --- a/doc/api/timers.md +++ b/doc/api/timers.md @@ -308,7 +308,7 @@ added: v0.0.1 --> * `timeout` {Timeout|string|number} A `Timeout` object as returned by [`setInterval()`][] - or the ID of the `Timeout` object as a string or a number. + or the [primitive][] of the `Timeout` object as a string or a number. Cancels a `Timeout` object created by [`setInterval()`][]. @@ -318,7 +318,7 @@ added: v0.0.1 --> * `timeout` {Timeout|string|number} A `Timeout` object as returned by [`setTimeout()`][] - or the ID of the `Timeout` object as a string or a number. + or the [primitive][] of the `Timeout` object as a string or a number. Cancels a `Timeout` object created by [`setTimeout()`][]. @@ -480,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