()
| 113 | } |
| 114 | |
| 115 | readString() { |
| 116 | const end = this.readVarint() + this.pos; |
| 117 | const pos = this.pos; |
| 118 | this.pos = end; |
| 119 | |
| 120 | if (end - pos >= TEXT_DECODER_MIN_LENGTH && utf8TextDecoder) { |
| 121 | // longer strings are fast with the built-in browser TextDecoder API |
| 122 | return utf8TextDecoder.decode(this.buf.subarray(pos, end)); |
| 123 | } |
| 124 | // short strings are fast with our custom implementation |
| 125 | return readUtf8(this.buf, pos, end); |
| 126 | } |
| 127 | |
| 128 | readBytes() { |
| 129 | const end = this.readVarint() + this.pos, |