stream-equal
Version:
Test that two readable streams are equal to each other.
50 lines (30 loc) • 1.58 kB
Markdown
Test that two readable streams are equal to each other.
[](https://www.npmjs.com/package/stream-equal)
[](https://github.com/fent/node-stream-equal/actions/workflows/nodejs.yml)
[](https://codecov.io/gh/fent/node-stream-equal)
```js
const streamEqual = require('stream-equal');
const fs = require('fs');
let readStream1 = fs.createReadStream(file);
let readStream2 = fs.createReadStream(file);
let equal = await streamEqual(readStream1, readStream2);
```
Useful for testing. This method of comparing is faster and uses less memory than buffering entire streams and comparing their content, specially for bigger files.
You could also get the hash sum of a stream to test it against another stream. Which is similar to what this library does, without the hashing.
A function that compares each `data` event on both streams, pausing when needed to keep them in sync. Returns a proimse that resolves to either `true` or `false`.
npm install stream-equal
Tests are written with [mocha](https://mochajs.org)
```bash
npm test
```
To report a security vulnerability, please use the
[](https://tidelift.com/security).
Tidelift will coordinate the fix and disclosure.