tunnel-stream
A test tunnel stream to simulate intermediate streams with different characteristics
Features
- should be readable and writable at both ends
- should cause the other end of the TunnelStream to emit data and end events on calls to write and end
- should support pause and resume but emit a paused data event when data arrives
- #pause
- should buffer multiple events separately
- #discardBufferedEvents
- should discard events buffered up to now while paused
- should support the setEncoding method
- should emit end events on both streams on end from one side
- should optionally rewrite data events into specified message sizes
- #flush
- should flush any unwritten buffered data due to a messageSize setting
Installation
npm install tunnel-stream
API
A simple use case
var TunnelStream = ; var tunnel = ; tunneldownstream;tunnelupstream; tunneldownstream; tunneldownstream; tunnelupstream; tunnelupstream; tunnelupstream;
To use pause and resume
var tunnel = ; tunneldownstream; tunneldownstream; tunneldownstream; tunneldownstream; tunnelupstream;tunnelupstream;
To set the message size
var tunnel = messageSize: 5; tunneldownstream;tunneldownstream;tunneldownstream; tunnelupstream;tunnelupstream;tunnelupstream; // ending the connection will flush the last few bytes // it is also possible to flush the last few bytes from the tunnel without ending the stream// by calling the flush method, eg...tunnelupstream;
Roadmap
- Nothing yet
Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using ./grunt.sh
or .\grunt.bat
.
License
Copyright (c) 2012 Peter Halliday
Licensed under the MIT license.