| 119 | } |
| 120 | |
| 121 | next(keyInfo: ElementInfo, valueInfo: ElementInfo) { |
| 122 | if (keyInfo.isNull || valueInfo.isNull) { |
| 123 | this.endChunk(); |
| 124 | this.header = this.writeHead(keyInfo, valueInfo, true); |
| 125 | this.preKeyInfo = keyInfo; |
| 126 | this.preValueInfo = valueInfo; |
| 127 | return this.header; |
| 128 | } |
| 129 | // max size of chunk is 255 |
| 130 | if ( |
| 131 | this.chunkSize == 255 |
| 132 | || this.chunkOffset == 0 |
| 133 | || !keyInfo.equalTo(this.preKeyInfo) |
| 134 | || !valueInfo.equalTo(this.preValueInfo) |
| 135 | ) { |
| 136 | // new chunk |
| 137 | this.endChunk(); |
| 138 | this.chunkSize++; |
| 139 | this.preKeyInfo = keyInfo; |
| 140 | this.preValueInfo = valueInfo; |
| 141 | return (this.header = this.writeHead(keyInfo, valueInfo)); |
| 142 | } |
| 143 | this.chunkSize++; |
| 144 | return this.header; |
| 145 | } |
| 146 | |
| 147 | endChunk() { |
| 148 | if (this.chunkOffset > 0) { |