PythonMonkey   v0.4.1 (dev)
Loading...
Searching...
No Matches
timers.js File Reference

Classes

class  Timeout
 

Functions

function _normalizeTimerArgs (handler, delayMs, additionalArgs)
 
function setTimeout (handler, delayMs=0,...args)
 
function clearTimeout (timeoutId)
 
function setInterval (handler, delayMs=0,...args)
 
 if (!globalThis.setTimeout) globalThis.setTimeout
 

Variables

const internalBinding = require('internal-binding')
 
 const
 
const clearInterval = clearTimeout
 
setTimeout Timeout = Timeout
 
exports setTimeout = setTimeout
 
exports clearTimeout = clearTimeout
 
exports setInterval = setInterval
 

Detailed Description

Author
Tom Tang xmade.nosp@m.r@di.nosp@m.strib.nosp@m.utiv.nosp@m.e.net.nosp@m.work
Date
May 2023

Function Documentation

◆ _normalizeTimerArgs()

function _normalizeTimerArgs (   handler,
  delayMs,
  additionalArgs 
)

Normalize the arguments to setTimeout or setInterval

Parameters
{Function| string} handler
{number}delayMs timeout milliseconds
{any[]}additionalArgs additional arguments to be passed to the handler

@type {Function}

◆ clearTimeout()

function clearTimeout (   timeoutId)

Implement the clearTimeout global function

See also
https://developer.mozilla.org/en-US/docs/Web/API/clearTimeout and
https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-cleartimeout
Parameters
{Timeout| number} timeoutId
Returns
{void}

◆ if()

if ( !globalThis.  setTimeout)

◆ setInterval()

function setInterval (   handler,
  delayMs = 0,
  args 
)

Implement the setInterval global function

See also
https://developer.mozilla.org/en-US/docs/Web/API/setInterval and
https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-setinterval
Parameters
{Function| string} handler
{number}delayMs timeout milliseconds, use value of 0 if this is omitted
{any[]}args additional arguments to be passed to the handler
Returns
{Timeout} timeoutId

◆ setTimeout()

function setTimeout (   handler,
  delayMs = 0,
  args 
)

Implement the setTimeout global function

See also
https://developer.mozilla.org/en-US/docs/Web/API/setTimeout and
https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-settimeout
Parameters
{Function| string} handler
{number}delayMs timeout milliseconds, use value of 0 if this is omitted
{any[]}args additional arguments to be passed to the handler
Returns
{Timeout} timeoutId

Variable Documentation

◆ clearInterval

exports clearInterval = clearTimeout

Implement the clearInterval global function @alias to clearTimeout

See also
https://developer.mozilla.org/en-US/docs/Web/API/clearInterval

◆ clearTimeout

exports clearTimeout = clearTimeout

◆ const

const
Initial value:
{
enqueueWithDelay,
cancelByTimeoutId,
timerHasRef,
timerAddRef,
timerRemoveRef,
} = internalBinding('timers')
const internalBinding
Definition timers.js:8

◆ internalBinding

function declare internalBinding = require('internal-binding')

internal binding helper for the setTimeout/setInterval global functions

UNSAFE, does not perform argument type checks

Parameters
repeatThe call is to setInterval if true
Returns
timeoutId

internal binding helper for the clearTimeout global function

internal binding helper for if a timer object has been ref'ed

internal binding helper for ref'ing the timer

internal binding helper for unref'ing the timer

◆ setInterval

exports setInterval = setInterval

◆ setTimeout

exports setTimeout = setTimeout

◆ Timeout