* Splits binary event-log message data into numbered chunks. * * @stability unstable * @since 4.0.0
(id: number, data: Uint8Array)
| 218 | * @since 4.0.0 |
| 219 | */ |
| 220 | static split(id: number, data: Uint8Array): NonEmptyReadonlyArray<ChunkedMessage> { |
| 221 | const parts = Math.max(1, Math.ceil(data.byteLength / ChunkedMessage.chunkSize)) |
| 222 | const result: NonEmptyArray<ChunkedMessage> = new Array(parts) as any |
| 223 | for (let i = 0; i < parts; i++) { |
| 224 | const start = i * ChunkedMessage.chunkSize |
| 225 | const end = Math.min((i + 1) * ChunkedMessage.chunkSize, data.byteLength) |
| 226 | result[i] = new ChunkedMessage({ |
| 227 | id, |
| 228 | part: [i, parts], |
| 229 | data: data.subarray(start, end) as any |
| 230 | }) |
| 231 | } |
| 232 | return result |
| 233 | } |
| 234 | |
| 235 | /** |
| 236 | * Reassembles all chunks for a message id into the original binary payload. |
no outgoing calls