Skip to content

Test that two readable streams are equal to each other.

License

Notifications You must be signed in to change notification settings

LinusU/node-stream-equal

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

node-stream-equal

Test that two readable streams are equal to each other.

Build Status Dependency Status

Usage

var streamEqual = require('stream-equal');
var fs = require('fs');

var readStream1 = fs.createReadStream(file);
var readStream2 = fs.createReadStream(file);
streamEqual(readStream1, readStream2, function(err, equal) {
  console.log(equal); // true
});

Motive

Useful for testing. This method is faster and uses much 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 the entire streams to be read if they are not equal.

API

streamEqual(readStream1, readStream2, callback(err, equal))

Will compare each data event on both streams, pausing when needed to keep them in sync. equal will be either true or false if there is no err.

Install

npm install stream-equal

Tests

Tests are written with mocha

npm test

License

MIT

About

Test that two readable streams are equal to each other.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%