<commit_before>class SearchResult {
  /**
   * @param {object} data - An element of array callbacked by search function.
   * @param {string} term
   * @param {Strategy} strategy
   */
  constructor(data, term, strategy) {
    this.data = data;
    this.term = term;
    this.strategy = strategy;
  }

  /**
   * @param {string} beforeCursor
   * @param {string} afterCursor
   * @returns {string[]|undefined}
   */
  replace(beforeCursor, afterCursor) {
    let replacement = this.strategy.replace(this.data);
    if (replacement != null) {
      if (Array.isArray(replacement)) {
        afterCursor = replacement[1] + afterCursor;
        replacement = replacement[0];
      }
      return [beforeCursor.replace(this.strategy.match, replacement), afterCursor];
    }
  }

  /**
   * @returns {string}
   */
  render() {
    return this.strategy.template(this.data, this.term);
  }
}

export default SearchResult;
<commit_msg>Flow src/search_result.js<commit_after>// @flow

export default class SearchResult {
  data: Object;
  term: string;
  strategy: any;

  /**
   * @param {object} data - An element of array callbacked by search function.
   * @param {string} term
   * @param {Strategy} strategy
   */
  constructor(data: Object, term: string, strategy: any) {
    this.data = data;
    this.term = term;
    this.strategy = strategy;
  }

  /**
   * @param {string} beforeCursor
   * @param {string} afterCursor
   * @returns {string[]|undefined}
   */
  replace(beforeCursor: string, afterCursor: string) {
    let replacement = this.strategy.replace(this.data);
    if (replacement != null) {
      if (Array.isArray(replacement)) {
        afterCursor = replacement[1] + afterCursor;
        replacement = replacement[0];
      }
      return [beforeCursor.replace(this.strategy.match, replacement), afterCursor];
    }
  }

  /**
   * @returns {string}
   */
  render(): string {
    return this.strategy.template(this.data, this.term);
  }
}

{'fraction_non_alphanumeric': 0.13585291113381, 'fraction_numerical': 0.0020429009193054137, 'mean_word_length': 2.981707317073171, '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': '1638787', 'n_tokens_mistral': 606, 'n_tokens_neox': 605, 'n_words': 142}