timers: document ref option for scheduler.wait

PR-URL: https://github.com/nodejs/node/pull/54605
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com>
This commit is contained in:
Paolo Insogna 2024-09-02 08:57:02 +02:00 committed by GitHub
parent 981c701400
commit 294ae14b98
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 13 deletions

View File

@ -525,6 +525,9 @@ added:
* `delay` {number} The number of milliseconds to wait before resolving the
promise.
* `options` {Object}
* `ref` {boolean} Set to `false` to indicate that the scheduled `Timeout`
should not require the Node.js event loop to remain active.
**Default:** `true`.
* `signal` {AbortSignal} An optional `AbortSignal` that can be used to
cancel waiting.
* Returns: {Promise}

View File

@ -131,22 +131,18 @@ function setImmediate(value, options = kEmptyObject) {
}
async function* setInterval(after, value, options = kEmptyObject) {
try {
if (typeof after !== 'undefined') {
validateNumber(after, 'delay');
}
if (typeof after !== 'undefined') {
validateNumber(after, 'delay');
}
validateObject(options, 'options');
validateObject(options, 'options');
if (typeof options?.signal !== 'undefined') {
validateAbortSignal(options.signal, 'options.signal');
}
if (typeof options?.signal !== 'undefined') {
validateAbortSignal(options.signal, 'options.signal');
}
if (typeof options?.ref !== 'undefined') {
validateBoolean(options.ref, 'options.ref');
}
} catch (err) {
return PromiseReject(err);
if (typeof options?.ref !== 'undefined') {
validateBoolean(options.ref, 'options.ref');
}
const { signal, ref = true } = options;