feat(UMP): Add support for partial parts

This commit is contained in:
Luan
2025-03-18 17:41:17 -03:00
parent 4ff9c14f94
commit d12432c0e5

View File

@@ -8,7 +8,7 @@ export class UMP {
this.chunkedDataBuffer = chunkedDataBuffer;
}
public parse(handlePart: (part: Part) => void) {
public parse(handlePart: (part: Part) => void): Part | undefined {
while (true) {
let offset = 0;
@@ -21,9 +21,16 @@ export class UMP {
if (partType < 0 || partSize < 0)
break;
// Note that we don't handle cases like this YET..
if (!this.chunkedDataBuffer.canReadBytes(offset, partSize))
break;
if (!this.chunkedDataBuffer.canReadBytes(offset, partSize)) {
if (!this.chunkedDataBuffer.canReadBytes(offset, 1))
break;
return {
type: partType,
size: partSize,
data: this.chunkedDataBuffer
};
}
const splitResult = this.chunkedDataBuffer.split(offset).remainingBuffer.split(partSize);
offset = 0;