JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 11529
  • Score
    100M100P100Q128040F
  • License MIT

Test that two readable streams are equal to each other.

Package Exports

  • stream-equal

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (stream-equal) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

node-stream-equal

Test that two readable streams are equal to each other.

Dependency Status codecov

Usage

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

npm test