* Ensure there's enough space in the current chunk for the next write. * If not, save the current chunk and allocate a new one.
(bytes: number)
| 21 | * If not, save the current chunk and allocate a new one. |
| 22 | */ |
| 23 | private ensureCapacity(bytes: number): void { |
| 24 | if (this.offset + bytes > this.chunkSize) { |
| 25 | // Save current chunk (trimmed to actual size used) |
| 26 | this.chunks.push(this.currentBuffer.slice(0, this.offset)); |
| 27 | // Allocate new chunk |
| 28 | this.currentBuffer = new ArrayBuffer(this.chunkSize); |
| 29 | this.currentView = new DataView(this.currentBuffer); |
| 30 | this.offset = 0; |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | writeUint8(value: number): void { |
| 35 | this.ensureCapacity(1); |
no outgoing calls
no test coverage detected