<commit_before>import { operations } from './constants';

export default class Events extends Map {
  constructor() {
    super();
    Object.keys(operations).forEach((key) => {
      this.set(operations[key], {});
    });
  }

  on(operation, collection, handler) {
    if (!this.get(operation)[collection]) {
      this.get(operation)[collection] = [];
    }
    this.get(operation)[collection].push(handler);
  }

  emit(operation, collection, ...rest) {
    return Promise.all(
      this.get(operation)[collection].map((handler) => handler(...rest))
    );
  }

  notify(options) {
    const { operation, collection, ...rest } = options;
    return this.emit(operation, collection, rest);
  }
}<commit_msg>bug fix<commit_after>import { operations } from './constants';

export default class Events extends Map {
  constructor() {
    super();
    Object.keys(operations).forEach((key) => {
      this.set(operations[key], {});
    });
  }

  on(operation, collection, handler) {
    if (!this.get(operation)[collection]) {
      this.get(operation)[collection] = [];
    }
    this.get(operation)[collection].push(handler);
  }

  emit(operation, collection, ...rest) {
    return Promise.all(
      (this.get(operation)[collection] || []).map((handler) => handler(...rest))
    );
  }

  notify(options) {
    const { operation, collection, ...rest } = options;
    return this.emit(operation, collection, rest);
  }
}
{'fraction_non_alphanumeric': 0.17837078651685392, 'fraction_numerical': 0.0, 'mean_word_length': 3.3445121951219514, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '4174264', 'n_tokens_mistral': 424, 'n_tokens_neox': 418, 'n_words': 78}