* Reads up to n bytes. * @param {number} n amount of bytes to read * @returns {Buffer} buffer with bytes
(n)
| 258 | * @returns {Buffer} buffer with bytes |
| 259 | */ |
| 260 | readUpTo(n) { |
| 261 | this.ensureBuffer(); |
| 262 | const rem = |
| 263 | /** @type {Buffer} */ (this.currentBuffer).length - this.currentPosition; |
| 264 | if (rem < n) { |
| 265 | n = rem; |
| 266 | } |
| 267 | const b = /** @type {Buffer} */ (this.currentBuffer); |
| 268 | const res = Buffer.from(b.buffer, b.byteOffset + this.currentPosition, n); |
| 269 | this.currentPosition += n; |
| 270 | this.checkOverflow(); |
| 271 | return res; |
| 272 | } |
| 273 | |
| 274 | /** |
| 275 | * Returns u8. |
no test coverage detected