* Reserve memory of the given capacity in the current write buffer * @this {!WriteBuffer} * @param {number} capacity Write buffer capacity
(capacity)
| 290 | * @param {number} capacity Write buffer capacity |
| 291 | */ |
| 292 | reserve (capacity) { |
| 293 | if (capacity < 0) { |
| 294 | throw new Error('Invalid reserve capacity!') |
| 295 | } |
| 296 | |
| 297 | if (capacity > this._buffer.length) { |
| 298 | let data = new Uint8Array(Math.max(capacity, 2 * this._buffer.length)) |
| 299 | data.set(this._buffer) |
| 300 | this._buffer = data |
| 301 | } |
| 302 | } |
| 303 | |
| 304 | /** |
| 305 | * Resize the current write buffer |