(needed)
| 1123 | } |
| 1124 | |
| 1125 | ensure_space(needed) { |
| 1126 | if (this.buffer.length - this.length >= needed) return; |
| 1127 | let new_capacity = this.buffer.length * 2; |
| 1128 | while (new_capacity - this.length < needed) new_capacity *= 2; |
| 1129 | let new_buffer = new Uint8Array(new_capacity); |
| 1130 | new_buffer.set(this.buffer); |
| 1131 | this.buffer = new_buffer; |
| 1132 | } |
| 1133 | |
| 1134 | trunc_buffer() { |
| 1135 | return new Uint8Array(this.buffer.buffer, 0, this.length); |
no test coverage detected