All files / src/abap/1_lexer lexer_buffer.ts

100% Statements 30/30
100% Branches 7/7
100% Functions 5/5
100% Lines 30/30

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 311x 1x 1x 1x 7868x 7868x 1x 1x 822098x 822098x 822098x 1x 1x 241632x 241632x 1x 1x 241632x 241632x 1x 1x 2429x 2429x 15391x 4925x 4925x 15391x 2429x 2429x 1x  
export class LexerBuffer {
  private buf: string;
 
  public constructor() {
    this.buf = "";
  }
 
  public add(s: string): string {
    this.buf = this.buf + s;
    return this.buf;
  }
 
  public get(): string {
    return this.buf;
  }
 
  public clear(): void {
    this.buf = "";
  }
 
  public countIsEven(char: string): boolean {
    let count = 0;
    for (let i = 0; i < this.buf.length; i += 1) {
      if (this.buf.charAt(i) === char) {
        count += 1;
      }
    }
    return count % 2 === 0;
  }
}