Skip to content

Commit

Permalink
timers: use kEmptyObject
Browse files Browse the repository at this point in the history
PR-URL: #43159
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
  • Loading branch information
LiviaMedeiros authored and targos committed Jul 31, 2022
1 parent d63c4c6 commit 3fbc5e4
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/timers/promises.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ const {
validateObject,
} = require('internal/validators');

const {
kEmptyObject,
} = require('internal/util');

const kScheduler = Symbol('kScheduler');

function cancelListenerHandler(clear, reject, signal) {
Expand All @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -131,7 +135,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');
Expand Down

0 comments on commit 3fbc5e4

Please sign in to comment.