flow-mock-write v1.0.1
flow-mock-write
Provides a mock source for writable streams.
Installation
$ npm install flow-mock-writeFor use in the browser, use browserify.
Usage
To create a mock for writing to writable streams,
var mock = require( 'flow-mock-write' );The method accepts two input arguments: an array of values to write and a writable stream.
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 writable stream:
var writable = eventStream.map( function( d, clbk ){
clbk( null, d.toString()+'\n' );
});
// Pipe to standard out:
writable.pipe( process.stdout );
// Start streaming...
mock( data, writable );Examples
To run the example code from the top-level application directory,
$ node ./examples/index.jsNotes
The mock implements the classic stream paradigm in Node; e.g., using write() and end() methods.
Tests
Unit
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 testAll new feature development should have corresponding unit tests to validate correct functionality.
Test Coverage
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-covIstanbul creates a ./reports/coverage directory. To access an HTML version of the report,
$ open reports/coverage/lcov-report/index.htmlLicense
Copyright
Copyright © 2014. Athan Reines.