* Reads any number of bytes and moves the offset. * if length not provided or it's larger than the remaining bytes, reads to end. * @param length * @returns {Buffer}
(length)
| 102 | * @returns {Buffer} |
| 103 | */ |
| 104 | read(length) { |
| 105 | let end = this.buf.length; |
| 106 | if (typeof length !== 'undefined' && this.offset + length < this.buf.length) { |
| 107 | end = this.offset + length; |
| 108 | } |
| 109 | const bytes = this.slice(this.offset, end); |
| 110 | this.offset = end; |
| 111 | return bytes; |
| 112 | } |
| 113 | |
| 114 | /** |
| 115 | * Moves the reader cursor to the end |
no test coverage detected