summaryrefslogtreecommitdiffstats
path: root/npm_assets/node_modules/livereload-js/lib/timer.js
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@unit193.net>2021-02-03 19:17:00 -0500
committerLibravatarUnit 193 <unit193@unit193.net>2021-02-03 19:17:00 -0500
commit3a0d66f07b112b6d2bdc2b57bbf717a89a351ce6 (patch)
treea7cf56282e54f05785243bc1e903d6594f2c06ba /npm_assets/node_modules/livereload-js/lib/timer.js
parent787b97a4cb24330b36f11297c6d3a7a473a907d0 (diff)
New upstream version 8.1.2.upstream/8.1.2
Diffstat (limited to 'npm_assets/node_modules/livereload-js/lib/timer.js')
-rw-r--r--npm_assets/node_modules/livereload-js/lib/timer.js42
1 files changed, 42 insertions, 0 deletions
diff --git a/npm_assets/node_modules/livereload-js/lib/timer.js b/npm_assets/node_modules/livereload-js/lib/timer.js
new file mode 100644
index 0000000..6d0e2c3
--- /dev/null
+++ b/npm_assets/node_modules/livereload-js/lib/timer.js
@@ -0,0 +1,42 @@
+(function() {
+ var Timer;
+
+ exports.Timer = Timer = (function() {
+ function Timer(func1) {
+ this.func = func1;
+ this.running = false;
+ this.id = null;
+ this._handler = (function(_this) {
+ return function() {
+ _this.running = false;
+ _this.id = null;
+ return _this.func();
+ };
+ })(this);
+ }
+
+ Timer.prototype.start = function(timeout) {
+ if (this.running) {
+ clearTimeout(this.id);
+ }
+ this.id = setTimeout(this._handler, timeout);
+ return this.running = true;
+ };
+
+ Timer.prototype.stop = function() {
+ if (this.running) {
+ clearTimeout(this.id);
+ this.running = false;
+ return this.id = null;
+ }
+ };
+
+ return Timer;
+
+ })();
+
+ Timer.start = function(timeout, func) {
+ return setTimeout(func, timeout);
+ };
+
+}).call(this);