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 <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
  • Loading branch information
LiviaMedeiros authored and danielleadams committed Jun 13, 2022
1 parent e576a7f commit fecad7a
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 @@ -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');
Expand Down

0 comments on commit fecad7a

Please sign in to comment.