MCPcopy
hub / github.com/di-sukharev/opencommit / readableStreamToArrayBuffer

Function readableStreamToArrayBuffer

out/cli.cjs:28696–28717  ·  view source on GitHub ↗
(readable)

Source from the content-addressed store, hash-verified

28694 Object.defineProperty(exports2, "__esModule", { value: true });
28695 exports2.readableStreamToArrayBuffer = readableStreamToArrayBuffer;
28696 async function readableStreamToArrayBuffer(readable) {
28697 const reader = readable.getReader();
28698 const chunks = [];
28699 let totalLength = 0;
28700 let done = false;
28701 while (!done) {
28702 const { value, done: doneReading } = await reader.read();
28703 if (doneReading) {
28704 done = true;
28705 } else {
28706 chunks.push(value);
28707 totalLength += value.length;
28708 }
28709 }
28710 const concatenatedChunks = new Uint8Array(totalLength);
28711 let offset = 0;
28712 for (const chunk of chunks) {
28713 concatenatedChunks.set(chunk, offset);
28714 offset += chunk.length;
28715 }
28716 return concatenatedChunks.buffer;
28717 }
28718 }
28719});
28720

Callers

nothing calls this directly

Calls 4

getReaderMethod · 0.45
readMethod · 0.45
pushMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…