* Validate that n bytes are available from current cursor position. * Throws ZR_TRUNCATED if buffer would be exceeded.
(n: number)
| 110 | * Throws ZR_TRUNCATED if buffer would be exceeded. |
| 111 | */ |
| 112 | private ensureAvailable(n: number): void { |
| 113 | if (this.off + n > this.byteLength) { |
| 114 | throw new ZrBinaryError({ |
| 115 | code: "ZR_TRUNCATED", |
| 116 | offset: this.off, |
| 117 | detail: `need ${n} byte(s) but only ${Math.max(0, this.byteLength - this.off)} remaining`, |
| 118 | }); |
| 119 | } |
| 120 | } |
| 121 | } |