<commit_before>import Module from 'parser/core/Module';
import { Event } from 'parser/core/Events';
import EventFilter from 'parser/core/EventFilter';
import EventEmitter from 'parser/core/modules/EventEmitter';

class EventHistory extends Module {

  /**
   * @param count the maximum number of events to return, or null for no limit
   * @param maxTime the maximum number of milliseconds to look back, or null for no limit
   * @param filterDef an optional EventFilter to apply to all events
   * @returns the last `count` events that match the given filters, with the oldest events first
   */
  public last<ET extends string, E extends Event<ET>>(count?: number, maxTime?: number, filterDef?: EventFilter<ET>): Array<E> {
    let filter = (event: Event<any>) => {
      return true;
    };

    if (maxTime) {
      const minTime = this.owner.currentTimestamp - maxTime;
      const prevFilter = filter;
      filter = (event: any) => {
        if (!event.timestamp || event.timestamp < minTime) {
          return false;
        }
        return prevFilter(event);
      };<commit_msg>Update EventHistory.last to used MappedEvents<commit_after>import Module from 'parser/core/Module';
import { Event, MappedEvent } from 'parser/core/Events';
import EventFilter from 'parser/core/EventFilter';
import EventEmitter from 'parser/core/modules/EventEmitter';

class EventHistory extends Module {

  /**
   * @param count the maximum number of events to return, or null for no limit
   * @param maxTime the maximum number of milliseconds to look back, or null for no limit
   * @param filterDef an optional EventFilter to apply to all events
   * @returns the last `count` events that match the given filters, with the oldest events first
   */
  public last<ET extends string, E extends MappedEvent<ET>>(count?: number, maxTime?: number, filterDef?: EventFilter<ET>): Array<E> {
    let filter = (event: Event<any>) => {
      return true;
    };

    if (maxTime) {
      const minTime = this.owner.currentTimestamp - maxTime;
      const prevFilter = filter;
      filter = (event: any) => {
        if (!event.timestamp || event.timestamp < minTime) {
          return false;
        }
        return prevFilter(event);
      };
{'fraction_non_alphanumeric': 0.1004034065441506, 'fraction_numerical': 0.0, 'mean_word_length': 3.3679060665362037, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, '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': '3213250', 'n_tokens_mistral': 602, 'n_tokens_neox': 599, 'n_words': 231}