(size: number)
| 9 | } |
| 10 | |
| 11 | private ensure(size: number): void { |
| 12 | const remaining = this.buffer.length - this.offset |
| 13 | if (remaining < size) { |
| 14 | const oldBuffer = this.buffer |
| 15 | // exponential growth factor of around ~ 1.5 |
| 16 | // https://stackoverflow.com/questions/2269063/buffer-growth-strategy |
| 17 | const newSize = oldBuffer.length + (oldBuffer.length >> 1) + size |
| 18 | this.buffer = Buffer.allocUnsafe(newSize) |
| 19 | oldBuffer.copy(this.buffer) |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | public addInt32(num: number): Writer { |
| 24 | this.ensure(4) |
no outgoing calls
no test coverage detected