<commit_before>class Extraction {
  constructor(id) {
    this.id = id;
    this.started = false;
    this.ended = false;
  }

  start() {
    if (this.started) {
      return this._consoleError('called start twice');
    }
    this.started = true;
    this._dispatch({
      id: this.id,
      type: 'START',
    });
  }

  data(obj) {
    if (!this.started) {
      return this._consoleError('sent data before starting', obj);
    }
    if (this.ended) {
      return this._consoleError('sent data after ending', obj);
    }
    this._dispatch({
      id: this.id,
      type: 'DATA',
      data: obj,
    });
  }

  error(error) {
    if (!this.started) {
      return this._consoleError('sent data before starting', obj);
    }
    if (this.ended) {
      return this._consoleError('sent data after ending', obj);
    }
    this._consoleError('errored:', error);
    this._dispatch({
      id: this.id,
      type: 'ERROR',
      data: (error instanceof Error) ? error.message : error,
    });
  }

  end() {
    if (this.ended) {
      return this._consoleError('called end twice');
    }
    this.ended = true;
    this._dispatch({
      id: this.id,
      type: 'END',
    });
  }
<commit_msg>fix undefined variable reference (#40)<commit_after>class Extraction {
  constructor(id) {
    this.id = id;
    this.started = false;
    this.ended = false;
  }

  start() {
    if (this.started) {
      return this._consoleError('called start twice');
    }
    this.started = true;
    this._dispatch({
      id: this.id,
      type: 'START',
    });
  }

  data(obj) {
    if (!this.started) {
      return this._consoleError('sent data before starting', obj);
    }
    if (this.ended) {
      return this._consoleError('sent data after ending', obj);
    }
    this._dispatch({
      id: this.id,
      type: 'DATA',
      data: obj,
    });
  }

  error(error) {
    if (!this.started) {
      return this._consoleError('sent data before starting', error);
    }
    if (this.ended) {
      return this._consoleError('sent data after ending', error);
    }
    this._consoleError('errored:', error);
    this._dispatch({
      id: this.id,
      type: 'ERROR',
      data: (error instanceof Error) ? error.message : error,
    });
  }

  end() {
    if (this.ended) {
      return this._consoleError('called end twice');
    }
    this.ended = true;
    this._dispatch({
      id: this.id,
      type: 'END',
    });
  }

{'fraction_non_alphanumeric': 0.14944421572663646, 'fraction_numerical': 0.0008233841086867024, 'mean_word_length': 2.2100396301188905, 'pattern_counts': {'":': 0, '<': 3, '<?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': '2472156', 'n_tokens_mistral': 803, 'n_tokens_neox': 777, 'n_words': 186}