<commit_before>function ModeManager() {
  this._modes = {};
  this._mode = null;
  this._defaultMode = null;
}

ModeManager.prototype.mode = function(mode, options) {
  if (mode) {
    if (this._modes[mode]) {
      if (this._mode && typeof this._modes[this._mode].deactivate === 'function') {
        this._modes[this._mode].deactivate(mode);
      }

      var old = this._mode;
      this._mode = mode;

      if (typeof this._modes[mode].activate === 'function') {
        this._modes[mode].activate(old, options);
      }

      console.log(old, '->', mode);
    } else {
      console.log('mode not registered:', mode);
    }
  }

  return this._mode;
};

ModeManager.prototype.add = function(name, fn) {
  this._modes[name] = fn;
}

ModeManager.prototype.handle = function(type, event) {
  event.modeManager = this;
  if (this._modes[this._mode] && this._modes[this._mode].handle) {
    if (!this._modes[this._mode].handle(type, event)) {

      if (this._defaultMode && this._modes[this._defaultMode].handle) {
        return this._modes[this._defaultMode].handle(type, event);
      }
    } else {
      return true;
    }
  }
}


ModeManager.prototype.update = function(delta) {

  if (this._modes[this._mode] && typeof this._modes[this._mode].update === 'function') {
    this._modes[this._mode].update(delta);
  }

  if (this._modes[this._defaultMode] && typeof this._modes[this._defaultMode].update === 'function') {
    this._modes[this._defaultMode].update(delta);
  }
};<commit_msg>expose to the window if not under node<commit_after>function ModeManager() {
  this._modes = {};
  this._mode = null;
  this._defaultMode = null;
}

ModeManager.prototype.mode = function(mode, options) {
  if (mode) {
    if (this._modes[mode]) {
      if (this._mode && typeof this._modes[this._mode].deactivate === 'function') {
        this._modes[this._mode].deactivate(mode);
      }

      var old = this._mode;
      this._mode = mode;

      if (typeof this._modes[mode].activate === 'function') {
        this._modes[mode].activate(old, options);
      }

      console.log(old, '->', mode);
    } else {
      console.log('mode not registered:', mode);
    }
  }

  return this._mode;
};

ModeManager.prototype.add = function(name, fn) {
  this._modes[name] = fn;
}

ModeManager.prototype.handle = function(type, event) {
  event.modeManager = this;
  if (this._modes[this._mode] && this._modes[this._mode].handle) {
    if (!this._modes[this._mode].handle(type, event)) {

      if (this._defaultMode && this._modes[this._defaultMode].handle) {
        return this._modes[this._defaultMode].handle(type, event);
      }
    } else {
      return true;
    }
  }
}

ModeManager.prototype.update = function(delta) {

  if (this._modes[this._mode] && typeof this._modes[this._mode].update === 'function') {
    this._modes[this._mode].update(delta);
  }

  if (this._modes[this._defaultMode] && typeof this._modes[this._defaultMode].update === 'function') {
    this._modes[this._defaultMode].update(delta);
  }
};

if (typeof module !== 'undefined' && module.exports) {
  module.exports = ModeManager;
} else {
  window.ModeManager = ModeManager;
}
{'fraction_non_alphanumeric': 0.16608557844690966, 'fraction_numerical': 0.0, 'mean_word_length': 3.2362416107382552, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '3253167', 'n_tokens_mistral': 1057, 'n_tokens_neox': 1005, 'n_words': 175}