Provides a mock sink for readable streams.
$ npm install flow-mock-read
For use in the browser, use browserify.
To create a mock sink (writeable) stream,
var mock = require( 'flow-mock-read' );
The method accepts two input arguments: a readable stream and a callback to invoke after reading all data values.
var eventStream = require( 'event-stream' );
// Simulate some data:
var data = new Array( 100 );
for ( var i = 0; i < data.length; i++ ) {
data[ i ] = Math.random()*100;
}
// Create a readable stream:
var readStream = eventStream.readArray( data );
// Start streaming...
mock( readStream, function onEnd( error, data ) {
console.log( JSON.stringify( data ) );
});
To run the example code from the top-level application directory,
$ node ./examples/index.js
The mock implements the classic stream paradigm in Node; e.g., using event listeners.
Unit tests use the Mocha test framework with Chai assertions. To run the tests, execute the following command in the top-level application directory:
$ make test
All new feature development should have corresponding unit tests to validate correct functionality.
This repository uses Istanbul as its code coverage tool. To generate a test coverage report, execute the following command in the top-level application directory:
$ make test-cov
Istanbul creates a ./reports/coverage
directory. To access an HTML version of the report,
$ open reports/coverage/lcov-report/index.html
Copyright © 2014. Athan Reines.