* Interpret the following bytes as a string, stopping at the next null byte or * the supplied limit. * * @param {number} [numBytes=-1] * @returns {string}
(numBytes=-1)
| 63 | * @returns {string} |
| 64 | */ |
| 65 | readString(numBytes=-1) { |
| 66 | if (this.position > this.length) return undefined; |
| 67 | |
| 68 | if (numBytes === -1) numBytes = this.length - this.position; |
| 69 | |
| 70 | let result = ""; |
| 71 | for (let i = this.position; i < this.position + numBytes; i++) { |
| 72 | const currentByte = this.bytes[i]; |
| 73 | if (currentByte === 0) break; |
| 74 | result += String.fromCharCode(currentByte); |
| 75 | } |
| 76 | this.position += numBytes; |
| 77 | this.bitPos = 0; |
| 78 | return result; |
| 79 | } |
| 80 | |
| 81 | /** |
| 82 | * Interpret the following bytes as an integer in big or little endian. |
no outgoing calls
no test coverage detected