prompt.once('run', () => { int = setInterval(() => { if (time-- === 0) { prompt.state.input = ''; prompt.cancel(); } else { prompt.render(); } }, 1000); });
function create(prompt, name, options = {}) { let timer = prompt.timers[name] = { name, start: Date.now(), ms: 0, tick: 0 }; let ms = options.interval || 120; timer.frames = options.frames || []; timer.loading = true; let interval = setInterval(() => { timer.ms = Date.now() - timer.start; timer.tick++; prompt.render(); }, ms); timer.stop = () => { timer.loading = false; clearInterval(interval); }; Reflect.defineProperty(timer, 'interval', { value: interval }); prompt.once('close', () => timer.stop()); return timer.stop; }
let i = 0; if (this.interval) this.stop(); this.interval = setInterval(() => { let choice = this.options.choices[i++]; if (choice && choice.includes(filter)) {
constructor(conf: ServerCfg) { this.log = logging; this.conf = conf || {} as ServerCfg; setInterval(() => { this.log.info('Nodes: ' + __(this.nodes).size() + ', ' + 'WebClients: ' + __(this.web_clients).size()); }, STATUS_INTERVAL); }
setupKeepAlive() { clearTimeout(this.reconnectId); clearTimeout(this.timeoutId); let self = this; this.keepaliveTimer = setInterval(function () { self.checkKeepAlive(); }, this.keepalive); }
function initReloadConfiguration(filename: string, reloadSecs: number) { if (configState.timerId) { clearInterval(configState.timerId); delete configState.timerId; } configState.filename = filename; configState.lastMTime = getMTime(filename); configState.timerId = setInterval(reloadConfiguration, reloadSecs * 1000); }
setupKeepAlive() { let self = this; this.keepaliveTimer = setInterval(function () { self.checkKeepAlive(); }, this.keepalive); }
this.socket.connect({ clientId: 'MQTT_RPC_' + Date.now() }, function () { if (self.connected) { return; } clearTimeout(connectTimeout); self.connected = true; if (self.bufferMsg) { self._interval = setInterval(function () { self.flush(self); }, self.interval); } self.setupKeepAlive(); });
getProfile(id: string, params: any, clientId: string, agent: MasterAgent) { let profile = this.profiles[params.type][params.uid]; let self = this; if (!profile || !profile.finish) { let timerId = setInterval(function () { profile = self.profiles[params.type][params.uid]; if (!!profile) { clearInterval(timerId); self.asyncGet(id, params, profile, clientId, agent); } }, 5000); } else { this.asyncGet(id, params, profile, clientId, agent); } }
async start() { this.tid = setInterval(this.flush.bind(this), this.flushInterval); }
/** * wrap setInterval * when time is Array, the interval time is thd random number * between then * *@param {Function} Fn *@param {Number} time */ interval(Fn: Function, time: any) { let fn = arguments[0]; let self = this; switch (typeof (time)) { case 'number': if (arguments[1] > 0) return setInterval(fn, arguments[1]); break; case 'object': let start = time[0], end = time[1]; let newTime: number = Math.round(Math.random() * (end - start) + start); return setTimeout(function () { fn(), self.interval(fn, newTime); }, newTime); default: self.log.error('wrong argument'); return; } }
setInterval(function() { self.checkKeepAlive(self); }, this.keepalive)
setupKeepAlive() { let self = this; this.keepaliveTimer = setInterval(function () { self.checkKeepAlive(); }, this.keepalive); }
setInterval(function() { self.checkKeepAlive(self); }, this.keepalive)
this.socket.connect({ clientId: 'MQTT_RPC_' + Date.now() }, function () { if (self.connected) { return; } clearTimeout(connectTimeout); self.connected = true; if (self.bufferMsg) { self._interval = setInterval(function () { self.flush(self); }, self.interval); } self.setupKeepAlive(); });