<commit_before>const { indexOf } = require('./utils/arr');

class Eventable {
  fire (event) {
    let listeners;
    const onEvent = 'on' + event.type;

    // Interactable#on() listeners
    if (event.type in this) {
      listeners = this[event.type];

      for (let i = 0, len = listeners.length; i < len && !event.immediatePropagationStopped; i++) {
        listeners[i](event);
      }
    }

    // interactable.onevent listener
    if (this[onEvent]) {
      this[onEvent](event);
    }

    // interact.on() listeners
    if (event.type in this.global && (listeners = this.global[event.type]))  {

      for (let i = 0, len = listeners.length; i < len && !event.immediatePropagationStopped; i++) {
        listeners[i](event);
      }
    }
  }

  on (eventType, listener) {
    // if this type of event was never bound
    if (!(eventType in this)) {
      this[eventType] = [listener];
    }
    else {
      this[eventType].push(listener);
    }<commit_msg>Eventable: check if this.global exists when firing<commit_after>const { indexOf } = require('./utils/arr');

class Eventable {
  fire (event) {
    let listeners;
    const onEvent = 'on' + event.type;
    const global = this.global;

    // Interactable#on() listeners
    if (event.type in this) {
      listeners = this[event.type];

      for (let i = 0, len = listeners.length; i < len && !event.immediatePropagationStopped; i++) {
        listeners[i](event);
      }
    }

    // interactable.onevent listener
    if (this[onEvent]) {
      this[onEvent](event);
    }

    // interact.on() listeners
    if (global && event.type in global && (listeners = global[event.type]))  {

      for (let i = 0, len = listeners.length; i < len && !event.immediatePropagationStopped; i++) {
        listeners[i](event);
      }
    }
  }

  on (eventType, listener) {
    // if this type of event was never bound
    if (!(eventType in this)) {
      this[eventType] = [listener];
    }
    else {
      this[eventType].push(listener);
    }
{'fraction_non_alphanumeric': 0.14783474365355898, 'fraction_numerical': 0.001991040318566451, 'mean_word_length': 2.483535528596187, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, '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': '6389947', 'n_tokens_mistral': 646, 'n_tokens_neox': 638, 'n_words': 160}