* Trim elements from the front of the buffer. * @param count the number of elements to trim (defaults to trimming the whole buffer.)
(keepMaxLines = 0)
| 390 | * @param count the number of elements to trim (defaults to trimming the whole buffer.) |
| 391 | */ |
| 392 | trim(keepMaxLines = 0) { |
| 393 | // figure out where the new head should be |
| 394 | const newHead = Math.max(this.head, this.last - keepMaxLines); |
| 395 | |
| 396 | // if we are actually trimming (and the head should move forward), then fill the elements with undefined |
| 397 | if (newHead > 0) { |
| 398 | this.#buffer.fill(undefined as unknown as string, this.head, newHead); |
| 399 | |
| 400 | // set the new head position |
| 401 | this.#head = newHead; |
| 402 | } |
| 403 | } |
| 404 | |
| 405 | /** returns a copy of the entire line buffer */ |
| 406 | all() { |
no outgoing calls