Created
January 2, 2024 22:54
-
-
Save codepunkt/ecca1395a251ca617b701e5b53c74150 to your computer and use it in GitHub Desktop.
Async Iterate over Node Readable stream
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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