mirror of https://github.com/nodejs/node.git
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
parent
44aa46d705
commit
cacd72eb63
|
@ -35,6 +35,10 @@ const {
|
||||||
validateObject,
|
validateObject,
|
||||||
} = require('internal/validators');
|
} = require('internal/validators');
|
||||||
|
|
||||||
|
const {
|
||||||
|
kEmptyObject,
|
||||||
|
} = require('internal/util');
|
||||||
|
|
||||||
const kScheduler = Symbol('kScheduler');
|
const kScheduler = Symbol('kScheduler');
|
||||||
|
|
||||||
function cancelListenerHandler(clear, reject, signal) {
|
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;
|
const args = value !== undefined ? [value] : value;
|
||||||
if (options == null || typeof options !== 'object') {
|
if (options == null || typeof options !== 'object') {
|
||||||
return PromiseReject(
|
return PromiseReject(
|
||||||
|
@ -88,7 +92,7 @@ function setTimeout(after, value, options = {}) {
|
||||||
() => signal.removeEventListener('abort', oncancel)) : ret;
|
() => signal.removeEventListener('abort', oncancel)) : ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setImmediate(value, options = {}) {
|
function setImmediate(value, options = kEmptyObject) {
|
||||||
if (options == null || typeof options !== 'object') {
|
if (options == null || typeof options !== 'object') {
|
||||||
return PromiseReject(
|
return PromiseReject(
|
||||||
new ERR_INVALID_ARG_TYPE(
|
new ERR_INVALID_ARG_TYPE(
|
||||||
|
@ -132,7 +136,7 @@ function setImmediate(value, options = {}) {
|
||||||
() => signal.removeEventListener('abort', oncancel)) : ret;
|
() => signal.removeEventListener('abort', oncancel)) : ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function* setInterval(after, value, options = {}) {
|
async function* setInterval(after, value, options = kEmptyObject) {
|
||||||
validateObject(options, 'options');
|
validateObject(options, 'options');
|
||||||
const { signal, ref = true } = options;
|
const { signal, ref = true } = options;
|
||||||
validateAbortSignal(signal, 'options.signal');
|
validateAbortSignal(signal, 'options.signal');
|
||||||
|
|
Loading…
Reference in New Issue