migme-ferry
Version:
Ferry transports packets to and from fusion/fission
45 lines (37 loc) • 1.52 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Lighthouse = function () {
function Lighthouse(time, cb) {
_classCallCheck(this, Lighthouse);
this._timeout = time;
this._cb = cb;
this._keepalive = null;
}
_createClass(Lighthouse, [{
key: "start",
value: function start() {
this._keepalive = this._keepalive || setInterval(this._cb, this._timeout);
}
}, {
key: "stop",
value: function stop() {
if (this._keepalive) {
clearInterval(this._keepalive);
this._keepalive = null;
}
}
}, {
key: "restart",
value: function restart() {
this.stop();
this.start();
}
}]);
return Lighthouse;
}();
exports.default = Lighthouse;
module.exports = exports['default'];