Code coverage report for src/util/MapPolyfill.ts

Statements: 96.43% (27 / 28)      Branches: 83.33% (5 / 6)      Functions: 100% (5 / 5)      Lines: 100% (26 / 26)      Ignored: none     

All files » src/util/ » MapPolyfill.ts
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 372 5 5 5   1 5 5     1 9 9 8 8 8   1   9     1 1 1 1 1 1 1     1 1 3     1
export class MapPolyfill {
  public size = 0;
  private _values: any[] = [];
  private _keys: any[] = [];
 
  get(key: any) {
    const i = this._keys.indexOf(key);
    return i === -1 ? undefined : this._values[i];
  }
 
  set(key: any, value: any) {
    const i = this._keys.indexOf(key);
    if (i === -1) {
      this._keys.push(key);
      this._values.push(value);
      this.size++;
    } else {
      this._values[i] = value;
    }
    return this;
  }
 
  delete(key: any): boolean {
    const i = this._keys.indexOf(key);
    Iif (i === -1) { return false; }
    this._values.splice(i, 1);
    this._keys.splice(i, 1);
    this.size--;
    return true;
  }
 
  forEach(cb: Function, thisArg: any) {
    for (let i = 0; i < this.size; i++) {
      cb.call(thisArg, this._values[i], this._keys[i]);
    }
  }
}