<commit_before>/**
 * event emitter
 */
export default class EventEmitter {
  /** @private */
  _handlers = new Map()
  /**
   * @param {string|Symbol} type
   * @param {function} handler
   */
  on (type, handler) {
    if (!this._handlers.has(type)) {
      this._handlers.set(type, new Set())
    }
    this._handlers.get(type).add(handler)
  }
  /**
   * @param {string|Symbol} type
   * @param {function} handler
   * @returns {boolean}
   */
  off (type, handler) {
    if (!this._handlers.has(type)) {
      return false
    }
    return this._handlers.get(type).delete(handler)
  }
  /**
   * @param {string|Symbol} type
   * @param {*} data
   */
  emit (type, data) {
    if (this._handlers.has(type)) {
      this._handlers.get(type).forEach(func => func(data))
    }
  }
}<commit_msg>refactor(event-emitter): add an internal method<commit_after>/**
 * event emitter
 */
export default class EventEmitter {
  /** @private */
  _handlers = new Map()
  /**
   * @param {string|Symbol} type
   * @param {function} handler
   */
  on (type, handler) {
    if (!this._has(type)) {
      this._handlers.set(type, new Set())
    }
    this._handlers.get(type).add(handler)
  }
  /**
   * @param {string|Symbol} type
   * @param {function} handler
   * @returns {boolean}
   */
  off (type, handler) {
    if (!this._has(type)) {
      return false
    }
    return this._handlers.get(type).delete(handler)
  }
  /**
   * @param {string|Symbol} type
   * @param {*} data
   */
  emit (type, data) {
    if (this._has(type)) {
      this._handlers.get(type).forEach(func => func(data))
    }
  }
  /**
   * @param {string|Symbol} type
   * @returns {boolean}
   */
  _has (type) {
    return this._handlers.has(type)
  }
}
{'fraction_non_alphanumeric': 0.175754060324826, 'fraction_numerical': 0.0, 'mean_word_length': 2.6012526096033404, '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': '4529172', 'n_tokens_mistral': 611, 'n_tokens_neox': 608, 'n_words': 123}