(output: string)
| 145 | } |
| 146 | |
| 147 | append(output: string): void { |
| 148 | if (!output) return; |
| 149 | |
| 150 | const previousTotal = this.totalCharacters; |
| 151 | this.totalCharacters += codePointLength(output); |
| 152 | |
| 153 | if (this.totalCharacters <= this.maxCharacters) { |
| 154 | this.head += output; |
| 155 | return; |
| 156 | } |
| 157 | |
| 158 | const budget = splitBudget(this.maxCharacters); |
| 159 | if (previousTotal <= this.maxCharacters) { |
| 160 | const fullOutput = this.head + output; |
| 161 | this.head = takeHead(fullOutput, budget.head); |
| 162 | this.tail = takeTail(fullOutput, budget.tail); |
| 163 | return; |
| 164 | } |
| 165 | |
| 166 | this.tail = takeTail(this.tail + output, budget.tail); |
| 167 | } |
| 168 | |
| 169 | hasOutput(): boolean { |
| 170 | return this.totalCharacters > 0; |
no test coverage detected