()
| 41 | }; |
| 42 | } |
| 43 | #readLine(): string | null { |
| 44 | if (this.#isEOF()) return null; |
| 45 | |
| 46 | let buffer = ""; |
| 47 | let hadNewline = false; |
| 48 | while (this.#cursor < this.#input.length) { |
| 49 | if (this.#input.startsWith("\r\n", this.#cursor)) { |
| 50 | hadNewline = true; |
| 51 | this.#cursor += 2; |
| 52 | break; |
| 53 | } |
| 54 | if ( |
| 55 | this.#input.startsWith("\n", this.#cursor) |
| 56 | ) { |
| 57 | hadNewline = true; |
| 58 | this.#cursor += 1; |
| 59 | break; |
| 60 | } |
| 61 | buffer += this.#input[this.#cursor]; |
| 62 | this.#cursor += 1; |
| 63 | } |
| 64 | if (!hadNewline && buffer.endsWith("\r")) { |
| 65 | buffer = buffer.slice(0, -1); |
| 66 | } |
| 67 | |
| 68 | return buffer; |
| 69 | } |
| 70 | #isEOF(): boolean { |
| 71 | return this.#cursor >= this.#input.length; |
| 72 | } |
no test coverage detected