https://github.com/fent/node-stream-equal
Test that two readable streams are equal to each other.
https://github.com/fent/node-stream-equal
node stream testing
Last synced: about 1 year ago
JSON representation
Test that two readable streams are equal to each other.
- Host: GitHub
- URL: https://github.com/fent/node-stream-equal
- Owner: fent
- License: mit
- Created: 2012-07-23T07:53:49.000Z (almost 14 years ago)
- Default Branch: master
- Last Pushed: 2023-05-11T03:45:37.000Z (about 3 years ago)
- Last Synced: 2024-08-10T21:43:15.543Z (almost 2 years ago)
- Topics: node, stream, testing
- Language: TypeScript
- Size: 237 KB
- Stars: 29
- Watchers: 3
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# node-stream-equal
Test that two readable streams are equal to each other.

[](https://codecov.io/gh/fent/node-stream-equal)
# Usage
```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);
```
# Motive
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.
# API
### async streamEqual(readStream1, readStream2)
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`.
# Install
npm install stream-equal
# Tests
Tests are written with [mocha](https://mochajs.org)
```bash
npm test
```
## Security contact information
To report a security vulnerability, please use the
[Tidelift security contact](https://tidelift.com/security).
Tidelift will coordinate the fix and disclosure.