(n: number)
| 1117 | |
| 1118 | // Takes exactly `n` bytes; the queue must hold at least `n` |
| 1119 | take(n: number): Uint8Array { |
| 1120 | if (n === 0) return new Uint8Array(0) |
| 1121 | const first = this.takeSome(n) |
| 1122 | if (first.length === n) return first |
| 1123 | const out = new Uint8Array(n) |
| 1124 | out.set(first) |
| 1125 | let filled = first.length |
| 1126 | while (filled < n) { |
| 1127 | const part = this.takeSome(n - filled) |
| 1128 | out.set(part, filled) |
| 1129 | filled += part.length |
| 1130 | } |
| 1131 | return out |
| 1132 | } |
| 1133 | |
| 1134 | clear(): void { |
| 1135 | this.chunks = [] |