PythonMonkey   v1.1.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 setImmediate (handler,...args)
 
function setInterval (handler, delayMs=0,...args)
 
 if (!globalThis.setTimeout) globalThis.setTimeout
 

Variables

const internalBinding = require('internal-binding')
 
 const
 
const clearImmediate = clearTimeout
 
const clearInterval = clearTimeout
 
setTimeout Timeout = Timeout
 
exports setTimeout = setTimeout
 
exports clearTimeout = clearTimeout
 
exports setImmediate = setImmediate
 
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,setImmediate 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)

◆ setImmediate()

function setImmediate (   handler,
  args 
)

Implement the setImmediate global function
NON-STANDARD, for Node.js compatibility only.

See also
https://developer.mozilla.org/en-US/docs/Web/API/Window/setImmediate and
https://nodejs.org/en/learn/asynchronous-work/understanding-setimmediate
Parameters
{Function| string} handler
{any[]}args additional arguments to be passed to the handler

◆ 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

◆ clearImmediate

exports clearImmediate = clearTimeout

Implement the clearImmediate global function
NON-STANDARD, for Node.js compatibility only. @alias to clearTimeout

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

◆ 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

Retrieve debug info inside the timer for the WTFPythonMonkey tool

Retrieve the debug info for all timers that are still ref'ed

◆ setImmediate

exports setImmediate = setImmediate

◆ setInterval

exports setInterval = setInterval

◆ setTimeout

exports setTimeout = setTimeout

◆ Timeout