MCPcopy Create free account
hub / github.com/nodejs/node / readAllBytes

Function readAllBytes

deps/undici/undici.js:5766–5786  ·  view source on GitHub ↗
(reader, successSteps, failureSteps)

Source from the content-addressed store, hash-verified

5764 }
5765 __name(readableStreamClose, "readableStreamClose");
5766 async function readAllBytes(reader, successSteps, failureSteps) {
5767 try {
5768 const bytes = [];
5769 let byteLength = 0;
5770 do {
5771 const { done, value: chunk } = await reader.read();
5772 if (done) {
5773 successSteps(Buffer.concat(bytes, byteLength));
5774 return;
5775 }
5776 if (!isUint8Array(chunk)) {
5777 failureSteps(new TypeError("Received non-Uint8Array chunk"));
5778 return;
5779 }
5780 bytes.push(chunk);
5781 byteLength += chunk.length;
5782 } while (true);
5783 } catch (e) {
5784 failureSteps(e);
5785 }
5786 }
5787 __name(readAllBytes, "readAllBytes");
5788 function urlIsLocal(url) {
5789 assert("protocol" in url);

Callers 1

fullyReadBodyFunction · 0.70

Calls 5

successStepsFunction · 0.85
isUint8ArrayFunction · 0.85
concatMethod · 0.80
readMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected