<commit_before>// https://www.codewars.com/kata/52d3b68215be7c2d5300022f

function Event() {
  this._subscribers = [];
}

Event.prototype.subscribe = function(fnc) {
  this._subscribers.push(fnc);
};

Event.prototype.unsubscribe = function(fnc) {
  var index = this._subscribers.findIndex(f => f === fnc);
  if (index !== -1) {
    delete this._subscribers[index];
  }
};

Event.prototype.emit = function(...args) {
  this._subscribers.forEach(handler => handler.apply(null, args));
}<commit_msg>splice() is better than delete in this case<commit_after>// https://www.codewars.com/kata/52d3b68215be7c2d5300022f

function Event() {
  this._subscribers = [];
}

Event.prototype.subscribe = function(fnc) {
  this._subscribers.push(fnc);
};

Event.prototype.unsubscribe = function(fnc) {
  var index = this._subscribers.findIndex(f => f === fnc);
  if (index !== -1) {
    this._subscribers.splice(index, 1);
  }
};

Event.prototype.emit = function(...args) {
  this._subscribers.forEach(handler => handler.apply(null, args));
}
{'fraction_non_alphanumeric': 0.17170731707317075, 'fraction_numerical': 0.03609756097560975, 'mean_word_length': 4.371727748691099, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '4179035', 'n_tokens_mistral': 393, 'n_tokens_neox': 374, 'n_words': 57}