-
Notifications
You must be signed in to change notification settings - Fork 223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to read entire stream into buffer #403
Comments
I totally agree. I persnally use https://www.npmjs.com/package/concat-stream. |
I would love to! But does it have any chance of being accepted? My main concern is about the "small core" argument. |
I don't know really. Considering that async iterators will be out of experimental in 12, I would recommend the following: const chunks = []
for await (let chunk of readable) {
chunks.push(chunk)
}
console.log(Buffer.concat(chunks)) |
That will not work on Node.js 8.x, will it? In our project, we need to support Node.js 8.x for as long as it's supported under the LTS policy (December 2019 at the time of writing). Would it make sense to add a new utility method, e.g. |
Yes. I will just use concat-stream until then, it's well maintained. |
You can do it using Fetch in Nodejs. Found the answer on here |
What is the recommended/idiomatic way for reading all data from a stream and store it in a buffer? Preferably using async/await style.
Example:
There are many userland modules in npm (e.g. get-stream and bl). The official example in Node.js docs is using
.on('data')
and.on('end')
callbacks.It would be great to have a built-in/native way for converting a readable stream into a buffer ✌️
The text was updated successfully, but these errors were encountered: