UNPKG

@fraserdarwent/xapi-node

Version:

This project is made possible to get data from Forex market, execute market or limit order with NodeJS/JS through WebSocket connection

37 lines 925 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Timer = void 0; class Timer { constructor() { this.interval = null; this.timeout = null; } setInterval(callback, ms) { this.clear(); this.interval = setInterval(() => { callback(); }, ms); } setTimeout(callback, ms) { this.clear(); this.timeout = setTimeout(() => { this.timeout = null; callback(); }, ms); } clear() { if (this.timeout !== null) { clearTimeout(this.timeout); this.timeout = null; } if (this.interval !== null) { clearInterval(this.interval); this.interval = null; } } isNull() { return this.interval === null && this.timeout === null; } } exports.Timer = Timer; //# sourceMappingURL=Timer.js.map