MCPcopy Create free account
hub / github.com/Ptechgithub/pp-worker / transform

Function transform

_worker.js:728–740  ·  view source on GitHub ↗
(chunk, controller)

Source from the content-addressed store, hash-verified

726
727 },
728 transform(chunk, controller) {
729 // udp message 2 byte is the the length of udp data
730 // TODO: this should have bug, beacsue maybe udp chunk can be in two websocket message
731 for (let index = 0; index < chunk.byteLength;) {
732 const lengthBuffer = chunk.slice(index, index + 2);
733 const udpPakcetLength = new DataView(lengthBuffer).getUint16(0);
734 const udpData = new Uint8Array(
735 chunk.slice(index + 2, index + 2 + udpPakcetLength)
736 );
737 index = index + 2 + udpPakcetLength;
738 controller.enqueue(udpData);
739 }
740 },
741 flush(controller) {
742 }
743 });

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected