<commit_before>import { List } from 'immutable';

export interface Metric {
  total: number;
  time: number;
}

export interface Amount<T extends Metric> {
  load: List<T>;
  treatAsInteger: boolean;
}

export interface IncrementOptions<T> {
  exponential?: boolean;
  extra?: any;
}

export type DecrementOptions<T> = IncrementOptions<T>;

export class Amount<T extends Metric> implements Amount<T> {
  constructor(load: List<T>, treatAsInteger: boolean = false) {
    this.load = load;
    this.treatAsInteger = treatAsInteger;
  }

  getAll():List<T> {
    return this.load;
  }

  first():T | undefined {
    return this.load.first();
  }

  last():T | undefined {
    return this.load.last();
  }

  current():T | undefined {
    return this.last();
  }

  push(n: T):void {
    this.load.push(n);
  }

  includes(v: T):boolean {
    return this.load.includes(v);
  }

  sortBy(prop: string) {
    return this.load.sortBy(metric => metric[prop]);
  }

  incremenet(inc: number, opts: IncrementOptions<T>) {
    const newAmount = opts.exponential ?
                      Math.pow(this.load.last().total, inc) :
                      this.load.last().total + inc;
    const newEntry:Metric = {
      total: this.treatAsInteger ? Math.round(newAmount) : newAmount,
      time: Date.now(),
    };
    this.load.push(<T>newEntry);
  }

  decrement(inc: number, opts: DecrementOptions<T>) {
    const newAmount = opts.exponential ?
                      Math.pow(this.load.last().total, inc) :
                      this.load.last().total - inc;
    const newEntry:Metric = {
      total: this.treatAsInteger ? Math.round(newAmount) : newAmount,
      time: Date.now(),<commit_msg>add proper type def to `sortBy`<commit_after>import { List, Iterable } from 'immutable';

export interface Metric {
  total: number;
  time: number;
}

export interface Amount<T extends Metric> {
  load: List<T>;
  treatAsInteger: boolean;
}

export interface IncrementOptions<T> {
  exponential?: boolean;
  extra?: any;
}

export type DecrementOptions<T> = IncrementOptions<T>;

export class Amount<T extends Metric> implements Amount<T> {
  constructor(load: List<T>, treatAsInteger: boolean = false) {
    this.load = load;
    this.treatAsInteger = treatAsInteger;
  }

  getAll():List<T> {
    return this.load;
  }

  first():T | undefined {
    return this.load.first();
  }

  last():T | undefined {
    return this.load.last();
  }

  current():T | undefined {
    return this.last();
  }

  push(n: T):void {
    this.load.push(n);
  }

  includes(v: T):boolean {
    return this.load.includes(v);
  }

  sortBy(prop: string):Iterable<number, T> {
    return this.load.sortBy((metric:any) => metric[prop]);
  }

  incremenet(inc: number, opts: IncrementOptions<T>) {
    const newAmount = opts.exponential ?
                      Math.pow(this.load.last().total, inc) :
                      this.load.last().total + inc;
    const newEntry:Metric = {
      total: this.treatAsInteger ? Math.round(newAmount) : newAmount,
      time: Date.now(),
    };
    this.load.push(<T>newEntry);
  }

  decrement(inc: number, opts: DecrementOptions<T>) {
    const newAmount = opts.exponential ?
                      Math.pow(this.load.last().total, inc) :
                      this.load.last().total - inc;
    const newEntry:Metric = {
      total: this.treatAsInteger ? Math.round(newAmount) : newAmount,
      time: Date.now(),
{'fraction_non_alphanumeric': 0.1411833626244874, 'fraction_numerical': 0.0, 'mean_word_length': 2.845720720720721, 'pattern_counts': {'":': 0, '<': 28, '<?xml version=': 0, '>': 30, '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': '53312', 'n_tokens_mistral': 1138, 'n_tokens_neox': 1101, 'n_words': 232}