https://github.com/compwright/read-entire-stream
Reads an entire stream's contents into a buffer. Made for ES6 and Node.js 16+.
https://github.com/compwright/read-entire-stream
async buffer es6 nodejs stream
Last synced: 4 months ago
JSON representation
Reads an entire stream's contents into a buffer. Made for ES6 and Node.js 16+.
- Host: GitHub
- URL: https://github.com/compwright/read-entire-stream
- Owner: compwright
- License: mit
- Created: 2022-11-04T16:07:59.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2022-11-04T16:34:55.000Z (about 3 years ago)
- Last Synced: 2025-08-09T14:52:52.494Z (5 months ago)
- Topics: async, buffer, es6, nodejs, stream
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/read-entire-stream
- Size: 107 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# read-entire-stream
[](https://www.npmjs.com/package/read-entire-stream)
[](https://github.com/sponsors/compwright)
Reads an entire stream's contents into a buffer.
Requires Node.js 16+
## Why
There are other options. Why this one?
A brief survey of NPM packages that more or less do this were:
* Antiquated and unmaintained
* Overly verbose
* Included one or more dependencies of unknown security status
* Do not support ES6
This package has no dependencies and was written with ES6 in mind.
In a mere 7 lines of code, it will take any Node.js [ReadableStream](https://nodejs.org/dist/latest-v18.x/docs/api/stream.html) and return a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) that resolves to a Node.js [Buffer](https://nodejs.org/dist/latest-v18.x/docs/api/buffer.html).
## Installation
With NPM:
$ npm install --save read-entire-stream
With Yarn:
$ yarn add read-entire-stream
## Usage
```javascript
import readEntireStream from 'read-entire-stream'
// ...
const buf = await readEntireStream(stream)
```
## Demo
See [bin/echo](bin/echo)
$ echo "Hello, world" | bin/echo
Hello, world
## License
MIT License