11 lines
261 B
JavaScript
11 lines
261 B
JavaScript
|
export async function streamToString(stream) {
|
||
|
// lets have a ReadableStream as a stream variable
|
||
|
const chunks = [];
|
||
|
|
||
|
for await (const chunk of stream) {
|
||
|
chunks.push(Buffer.from(chunk));
|
||
|
}
|
||
|
|
||
|
return Buffer.concat(chunks).toString("utf-8");
|
||
|
}
|