<commit_before>udefine(['eventmap', 'performance'], function(EventMap, performance) {

  var Timer = function(interval) {
    EventMap.mixin(this, Timer.prototype);
    
    var self = this;

    this.interval = interval || 1000;
    this.startTime = -1;

    this.active = false;
    this.paused = false;

    var oldTicks = 0;

    this.tick = function(currentTime) {
      if (!self.active || self.paused) {
        return;
      }
      
      if (interval <= 0) {
        return;
      }

      self.trigger('tick', currentTime);

      if ((currentTime - self.startTime - self.interval) > oldTicks) {
        oldTicks = currentTime;
        self.trigger('interval');
      }
    };
  };

  Timer.prototype.start = function() {
    this.active = true;
    this.paused = false;

    this.startTime = performance.now();

    this.trigger('start');
  };

  Timer.prototype.pause = function() {
    this.paused = true;

    this.trigger('pause');
  };

  Timer.prototype.unpause = function() {
    this.paused = false;

    this.trigger('unpause');
  };

  Timer.prototype.stop = function() {
    this.paused = false;
    this.active = false;

    this.trigger('stop');
  };
  
  return Timer;

});<commit_msg>:fire: Update Timer to ES6<commit_after>'use strict';

import EventMap from 'eventmap';
import performance from 'performance';

class Timer extends EventMap {
  constructor(interval) {
    this.interval = interval || 1000;
    this.startTime = -1;

    this.active = false;
    this.paused = false;

    var oldTicks = 0;

    this.tick = (currentTime) => {
      if (!this.active || this.paused) {
        return;
      }

      if (interval <= 0) {
        return;
      }

      this.trigger('tick', currentTime);

      if ((currentTime - this.startTime - this.interval) > oldTicks) {
        oldTicks = currentTime;
        this.trigger('interval');
      }
    };
  }

  start() {
    this.active = true;
    this.paused = false;

    this.startTime = performance.now();

    this.trigger('start');
  }

  pause() {
    this.paused = true;

    this.trigger('pause');
  }

  unpause() {
    this.paused = false;

    this.trigger('unpause');
  }

  stop() {
    this.paused = false;
    this.active = false;

    this.trigger('stop');
  }
}

export default Timer;
{'fraction_non_alphanumeric': 0.14692982456140352, 'fraction_numerical': 0.006578947368421052, 'mean_word_length': 2.315406976744186, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6457994', 'n_tokens_mistral': 786, 'n_tokens_neox': 718, 'n_words': 148}