@nuxthub/core
Version:
Build full-stack Nuxt applications on Cloudflare, with zero configuration.
15 lines (14 loc) • 356 B
JavaScript
export async function streamToArrayBuffer(stream, streamSize) {
const result = new Uint8Array(streamSize);
let bytesRead = 0;
const reader = stream.getReader();
while (true) {
const { done, value } = await reader.read();
if (done) {
break;
}
result.set(value, bytesRead);
bytesRead += value.length;
}
return result;
}