* Get all items currently in the buffer, in order from oldest to newest.
()
| 55 | * Get all items currently in the buffer, in order from oldest to newest. |
| 56 | */ |
| 57 | toArray(): T[] { |
| 58 | if (this.size === 0) return [] |
| 59 | |
| 60 | const result: T[] = [] |
| 61 | const start = this.size < this.capacity ? 0 : this.head |
| 62 | |
| 63 | for (let i = 0; i < this.size; i++) { |
| 64 | const index = (start + i) % this.capacity |
| 65 | result.push(this.buffer[index]!) |
| 66 | } |
| 67 | |
| 68 | return result |
| 69 | } |
| 70 | |
| 71 | /** |
| 72 | * Clear all items from the buffer. |
no outgoing calls
no test coverage detected