mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
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>
This commit is contained in:
committed by
Antoine du Hamel
parent
44aa46d705
commit
cacd72eb63
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user