Skip to content

Latest commit

 

History

History
40 lines (40 loc) · 948 Bytes

HOW-TO.md

File metadata and controls

40 lines (40 loc) · 948 Bytes
nav-title title description
timer How-To
How-To
Examples for using timer

Timer module

How to require timer module

require("globals");
// OR
var timer = require("timer");

Evaluates an expression after 0 milliseconds.

timer.setTimeout(function () {
});

Evaluates an expression after a specified number of milliseconds.

timer.setTimeout(function () {
}, 500);

Cancels the evaluation with the clearTimeout method.

var id = timer.setTimeout(function () {
}, 2000);
// Clear timeout with specified id.
timer.clearTimeout(id);

Evaluates an expression each time a specified number of milliseconds has elapsed.

timer.setInterval(function () {
}, 100);

Cancel the interval previously started using the setInterval method.

var id = timer.setInterval(function () {
    timer.clearInterval(id);
}, 100);