mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
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:
parent
981c701400
commit
294ae14b98
@ -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}
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user