flow-mock-write
v1.0.1
Published
Provides a mock source for writable streams.
Downloads
9
Maintainers
Readme
flow-mock-write
Provides a mock source for writable streams.
Installation
$ npm install flow-mock-write
For 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.js
Notes
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 test
All 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-cov
Istanbul creates a ./reports/coverage
directory. To access an HTML version of the report,
$ open reports/coverage/lcov-report/index.html
License
Copyright
Copyright © 2014. Athan Reines.