-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstopwatch.min.js
1 lines (1 loc) · 1.1 KB
/
stopwatch.min.js
1
(function(){var Stopwatch,__bind=function(fn,me){return function(){return fn.apply(me,arguments)}};Stopwatch=function(){var interval;Stopwatch.prototype.config={accuracy:1e3};Stopwatch.prototype.value=0;Stopwatch.prototype.laps=[];interval=null;function Stopwatch(config){this.config=config!=null?config:this.config;this.update=__bind(this.update,this)}Stopwatch.prototype.start=function(){return interval=setInterval(this.update,this.config.accuracy)};Stopwatch.prototype.stop=function(){clearInterval(interval);return interval=null};Stopwatch.prototype.reset=function(){if(interval!=null){this.stop()}this.laps=[];return this.value=0};Stopwatch.prototype.lap=function(){return this.laps.push(this.value)};Stopwatch.prototype.running=function(){if(interval!=null){return true}else{return false}};Stopwatch.prototype.update=function(){return this.value++};return Stopwatch}();if(typeof module!=="undefined"&&module!==null){module.exports=Stopwatch}if(typeof ender==="undefined"||ender===null){this.Stopwatch=Stopwatch}if(typeof define==="function"&&define.amd){define("Stopwatch",[],function(){return Stopwatch})}}).call(this);