MCPcopy Create free account
hub / github.com/Ridter/cf_workers_proxy / transform

Function transform

js/worker.js:537–549  ·  view source on GitHub ↗
(chunk, controller)

Source from the content-addressed store, hash-verified

535
536 },
537 transform(chunk, controller) {
538 // udp message 2 byte is the the length of udp data
539 // TODO: this should have bug, beacsue maybe udp chunk can be in two websocket message
540 for (let index = 0; index < chunk.byteLength;) {
541 const lengthBuffer = chunk.slice(index, index + 2);
542 const udpPakcetLength = new DataView(lengthBuffer).getUint16(0);
543 const udpData = new Uint8Array(
544 chunk.slice(index + 2, index + 2 + udpPakcetLength)
545 );
546 index = index + 2 + udpPakcetLength;
547 controller.enqueue(udpData);
548 }
549 },
550 flush(controller) {
551 }
552 });

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected