MCPcopy Create free account
hub / github.com/Ptechgithub/configs / transform

Function transform

worker.js:652–664  ·  view source on GitHub ↗
(chunk, controller)

Source from the content-addressed store, hash-verified

650
651 },
652 transform(chunk, controller) {
653 // udp message 2 byte is the the length of udp data
654 // TODO: this should have bug, beacsue maybe udp chunk can be in two websocket message
655 for (let index = 0; index < chunk.byteLength;) {
656 const lengthBuffer = chunk.slice(index, index + 2);
657 const udpPakcetLength = new DataView(lengthBuffer).getUint16(0);
658 const udpData = new Uint8Array(
659 chunk.slice(index + 2, index + 2 + udpPakcetLength)
660 );
661 index = index + 2 + udpPakcetLength;
662 controller.enqueue(udpData);
663 }
664 },
665 flush(controller) {
666 }
667 });

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected