All files main.ts

100% Statements 19/19
100% Branches 5/5
100% Functions 9/9
100% Lines 17/17

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 37 38 391x       7x     1x 11x 48x         8x       1x 15x 85x 15x 85x       15x     1x 23x 23x       8x   1x  
export class Main {
  string: string
 
  constructor (string: string) {
    this.string = string
  }
 
  public erase (): void {
    if (this.hasErased) {
      this.splited = this.splited.map(string => (
        string[0] === undefined
          ? ''
          : string.slice(1)
      ))
      this.erase()
    }
  }
 
  get hasErased (): boolean {
    const noUndefinedStrings = this.splited
      .filter(string => string !== undefined)
    const result = noUndefinedStrings
      .filter(string => (
        string[0] === ' ' ||
        string[0] === undefined
      )).length === noUndefinedStrings.length
    return result
  }
 
  get splited (): string[] {
    const result = this.string.split('\n')
    return result
  }
 
  set splited (splited) {
    this.string = splited.join('\n')
  }
}