(needed)
| 670 | } |
| 671 | |
| 672 | ensure_space(needed) { |
| 673 | if (this.buffer.length - this.length >= needed) return; |
| 674 | let new_capacity = this.buffer.length * 2; |
| 675 | while (new_capacity - this.length < needed) new_capacity *= 2; |
| 676 | let new_buffer = new Uint8Array(new_capacity); |
| 677 | new_buffer.set(this.buffer); |
| 678 | this.buffer = new_buffer; |
| 679 | } |
| 680 | |
| 681 | trunc_buffer() { |
| 682 | return new Uint8Array(this.buffer.buffer, 0, this.length); |
no test coverage detected