timers: use `kEmptyObject`

PR-URL: https://github.com/nodejs/node/pull/43159
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
pull/43159/head
LiviaMedeiros 2022-05-21 17:56:32 +08:00 committed by Antoine du Hamel
parent 44aa46d705
commit cacd72eb63
No known key found for this signature in database
GPG Key ID: 21D900FFDB233756
1 changed files with 7 additions and 3 deletions

View File

@ -35,6 +35,10 @@ const {
validateObject,
} = require('internal/validators');
const {
kEmptyObject,
} = require('internal/util');
const kScheduler = Symbol('kScheduler');
function cancelListenerHandler(clear, reject, signal) {
@ -44,7 +48,7 @@ function cancelListenerHandler(clear, reject, signal) {
}
}
function setTimeout(after, value, options = {}) {
function setTimeout(after, value, options = kEmptyObject) {
const args = value !== undefined ? [value] : value;
if (options == null || typeof options !== 'object') {
return PromiseReject(
@ -88,7 +92,7 @@ function setTimeout(after, value, options = {}) {
() => signal.removeEventListener('abort', oncancel)) : ret;
}
function setImmediate(value, options = {}) {
function setImmediate(value, options = kEmptyObject) {
if (options == null || typeof options !== 'object') {
return PromiseReject(
new ERR_INVALID_ARG_TYPE(
@ -132,7 +136,7 @@ function setImmediate(value, options = {}) {
() => signal.removeEventListener('abort', oncancel)) : ret;
}
async function* setInterval(after, value, options = {}) {
async function* setInterval(after, value, options = kEmptyObject) {
validateObject(options, 'options');
const { signal, ref = true } = options;
validateAbortSignal(signal, 'options.signal');