Skip to content

Instantly share code, notes, and snippets.

@codepunkt
Created January 2, 2024 22:54
Show Gist options
  • Save codepunkt/ecca1395a251ca617b701e5b53c74150 to your computer and use it in GitHub Desktop.
Save codepunkt/ecca1395a251ca617b701e5b53c74150 to your computer and use it in GitHub Desktop.
Async Iterate over Node Readable stream
async function streamToString(stream: Readable) {
const chunks: Buffer[] = [];
for await (const chunk of stream) {
chunks.push(Buffer.from(chunk));
}
return Buffer.concat(chunks).toString('utf-8');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment