# stream-equal

> Test that two readable streams are equal to each other.

Latest version **2.0.1** (published 2020-07-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install stream-equal
pnpm add stream-equal
yarn add stream-equal
bun add stream-equal
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.1 |
| Published | 2020-07-07 |
| First published | 2012-07-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=10 |
| Dependencies | 0 |
| Unpacked size | 11 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 30 |
| Author | fent |
| Maintainers | fent |
| Keywords | stream, input, output, io, assert, test |

## Links

- npm: https://www.npmjs.com/package/stream-equal
- Repository: https://github.com/fent/node-stream-equal
- Homepage: https://github.com/fent/node-stream-equal#readme
- Issues: https://github.com/fent/node-stream-equal/issues
- npm.io page: https://npm.io/package/stream-equal

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [vest](https://npm.io/package/vest.md) — 50.1K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads

## Recent versions

- 2.0.1 (latest) — 2020-07-07
- 2.0.0 — 2020-05-31
- 1.1.1 — 2018-03-13
- 1.1.0 — 2017-10-08
- 1.0.1 — 2017-08-10
- 1.0.0 — 2017-03-02
- 0.1.13 — 2017-02-11
- 0.1.12 — 2016-12-05
- 0.1.11 — 2016-11-23
- 0.1.9 — 2016-10-22
- 0.1.8 — 2016-01-30
- 0.1.7 — 2015-10-22
- 0.1.6 — 2015-10-15
- 0.1.5 — 2013-03-19
- 0.1.4 — 2013-03-17
- … 3 more at https://npm.io/package/stream-equal/versions

## README

# node-stream-equal

Test that two readable streams are equal to each other.

[![Dependency Status](https://david-dm.org/fent/node-stream-equal.svg)](https://david-dm.org/fent/node-stream-equal)
[![codecov](https://codecov.io/gh/fent/node-stream-equal/branch/master/graph/badge.svg)](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. But that would take up more CPU due to the hashing and would require a bit more data to be read if they are not equal.


# 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
```

---
_Source: https://npm.io/package/stream-equal · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
