| 69 | } |
| 70 | |
| 71 | write(chunk) { |
| 72 | if (this.#cursor >= chunk.length) { |
| 73 | this.#cursor -= chunk.length; |
| 74 | return; |
| 75 | } |
| 76 | |
| 77 | if (this.#next) { |
| 78 | if (this.#next(chunk) || this.#cursor >= chunk.length) { |
| 79 | this.#cursor -= chunk.length; |
| 80 | return; |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | do { |
| 85 | const type = chunk[this.#cursor]; |
| 86 | if (++this.#cursor === chunk.length) { |
| 87 | this.#next = this.#continueDecodeTypeValue.bind(this, type); |
| 88 | break; |
| 89 | } |
| 90 | |
| 91 | if (this.#decodeTypeValue(type, chunk)) { |
| 92 | break; |
| 93 | } |
| 94 | } while (this.#cursor < chunk.length); |
| 95 | this.#cursor -= chunk.length; |
| 96 | } |
| 97 | |
| 98 | #continueDecodeTypeValue(type, chunk) { |
| 99 | this.#next = undefined; |