timers

The timers module provides access to web-like timing functionality.

API Reference

Functions

setTimeout(callback, ms)

Schedules callback to be called in ms milliseconds. Any additional arguments are passed straight through to the callback.

callback : function

Function to be called.

ms : integer

Interval in milliseconds after which the function will be called.

Returns: integer

An ID that can later be used to undo this scheduling, if callback hasn't yet been called.

clearTimeout(ID)

Given an ID returned from setTimeout(), prevents the callback with the ID from being called (if it hasn't yet been called).

ID : integer

An ID returned from setTimeout().

setInterval(callback, ms)

Schedules callback to be called repeatedly every ms milliseconds. Any additional arguments are passed straight through to the callback.

callback : function

Function to be called.

ms : integer

Interval in milliseconds at which the function will be called.

Returns: integer

An ID that can later be used to unschedule the callback.

clearInterval(ID)

Given an ID returned from setInterval(), prevents the callback with the ID from being called again.

ID : integer

An ID returned from setInterval().