| 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 | |