<commit_before>function TimerRepository() {
  this.uid = 1;
  this.timers = [];  
}

TimerRepository.prototype.insertTimer = function(timer) {

  timer.uid = this.uid++;
  var i;
  for(i = 0; i < this.timers.length; ++i) {
    if(this.timers[i].dueTime > timer.dueTime) {
	  break;
	}
  }
  
  this.timers.splice(i, 0, timer);
};

TimerRepository.prototype.removeTimer = function(timer) {
  var i;
  for(i = 0; i < this.timers.length; ++i) {
    if(this.timers[i].uid === timer.uid) {
	  break;
	}
  }
  
  this.timers.splice(i, 1);
};

TimerRepository.prototype.nextTimer = function() {
  return this.timers[0];
};

module.exports = TimerRepository;<commit_msg>Removed duplication where findIndex was better<commit_after>function TimerRepository() {
  this.uid = 1;
  this.timers = [];  
}

TimerRepository.prototype.insertTimer = function(timer) {

  timer.uid = this.uid++;
  var i;
  for(i = 0; i < this.timers.length; ++i) {
    if(this.timers[i].dueTime > timer.dueTime) {
	  break;
	}
  }
  
  this.timers.splice(i, 0, timer);
};

TimerRepository.prototype.removeTimer = function(timer) {
  var toRemove = this.timers.findIndex(function(analysed) {
    return analysed.uid > timer.uid;
  };
  assert(toRemove !== -1);
  
  this.timers.splice(toRemove, 1);
};

TimerRepository.prototype.nextTimer = function() {
  return this.timers[0];
};

module.exports = TimerRepository;
{'fraction_non_alphanumeric': 0.16231884057971013, 'fraction_numerical': 0.008695652173913044, 'mean_word_length': 3.634228187919463, 'pattern_counts': {'":': 0, '<': 6, '<?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': '4520887', 'n_tokens_mistral': 528, 'n_tokens_neox': 506, 'n_words': 86}