Skip to content

Instantly share code, notes, and snippets.

@sukima
Created November 7, 2014 23:13
Show Gist options
  • Save sukima/ec59fad8adcd49643530 to your computer and use it in GitHub Desktop.
Save sukima/ec59fad8adcd49643530 to your computer and use it in GitHub Desktop.
var checkStream = function(stream, callback, expectations) {
var results = [];
return stream.on('data', function(chunk) {
results.push(chunk);
})
.once('error', callback)
.once('end', function() {
try {
expectations.call(stream, results);
callback();
} catch(err) {
callback(err);
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment