"use strict";
/**
 * @module timers
 */
Object.defineProperty(exports, "__esModule", { value: true });
/**
 * Fires a callback function after the specified time elapses.
 * @param cb function to execute after time elapses
 * @param ms milliseconds to wait before executing
 * @return an ID for the newly created timeout
 */
function setTimeout(cb, ms) {
    const ref = bridge.wrapFunction(cb);
    return bridge.dispatchSync("setTimeout", ref, ms);
}
exports.setTimeout = setTimeout;
/**
 * Cancels a previously specified timeout
 * @param id the id of the timeout to cancel
 */
function clearTimeout(id) {
    bridge.dispatch("clearTimeout", id);
}
exports.clearTimeout = clearTimeout;
/**
 * Fires a callback after the current task yields
 * @param cb The callback to fire asynchronously
 */
function setImmediate(cb) {
    setTimeout(cb, 0);
}
exports.setImmediate = setImmediate;
/**
 * Fires a callback over and over
 * @param cb The callback to fire every <ms> milliseconds
 * @param ms Milliseconds to wait between intervals
 * @return id of newly created interval
 */
function setInterval(cb, ms) {
    const ref = bridge.wrapFunction(cb);
    return bridge.dispatchSync("setInterval", ref, ms);
}
exports.setInterval = setInterval;
/**
 * Cancels the previously created interval
 * @param id The interval ID to cancel
 */
function clearInterval(id) {
    bridge.dispatch("clearInterval", id);
}
exports.clearInterval = clearInterval;
//# sourceMappingURL=timers.js.map