/
astafievk
/
source_code
Обзор
Документация
Войти
/
astafievk
/
source_code
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
Api/node_modules/mysql/lib/protocol/Timer.js
33 строки
699 B
astafievK
source code
21 июн 2024, 21:02
21 июн 2024, 21:02
37a1d03
Код
Авторство
О чём код?
var Timers = require('timers'); module.exports = Timer; function Timer(object) { this._object = object; this._timeout = null; } Timer.prototype.active = function active() { if (this._timeout) { if (this._timeout.refresh) { this._timeout.refresh(); } else { Timers.active(this._timeout); } } }; Timer.prototype.start = function start(msecs) { this.stop(); this._timeout = Timers.setTimeout(this._onTimeout.bind(this), msecs); }; Timer.prototype.stop = function stop() { if (this._timeout) { Timers.clearTimeout(this._timeout); this._timeout = null; } }; Timer.prototype._onTimeout = function _onTimeout() { return this._object._onTimeout(); };