(data: string, isStderr: boolean)
| 174 | } |
| 175 | |
| 176 | #writeBuffered(data: string, isStderr: boolean): void { |
| 177 | this.#totalBytes += data.length |
| 178 | |
| 179 | this.#updateProgress(data) |
| 180 | |
| 181 | // Write to disk if already overflowed |
| 182 | if (this.#disk) { |
| 183 | this.#disk.append(isStderr ? `[stderr] ${data}` : data) |
| 184 | return |
| 185 | } |
| 186 | |
| 187 | // Check if this chunk would exceed the in-memory limit |
| 188 | const totalMem = |
| 189 | this.#stdoutBuffer.length + this.#stderrBuffer.length + data.length |
| 190 | if (totalMem > this.#maxMemory) { |
| 191 | this.#spillToDisk(isStderr ? data : null, isStderr ? null : data) |
| 192 | return |
| 193 | } |
| 194 | |
| 195 | if (isStderr) { |
| 196 | this.#stderrBuffer += data |
| 197 | } else { |
| 198 | this.#stdoutBuffer += data |
| 199 | } |
| 200 | } |
| 201 | |
| 202 | /** |
| 203 | * Single backward pass: count all newlines (for totalLines) and extract |
no test coverage detected