PEEKSTREAM is a simple filtering stream that collects and buffers data inside a configured window as they're being streamed.
Useful for taking a peek at streaming logs or sampling data at intervals.
Also very useful for testing complex stream interactions.
npm install --save peekstream
var peek = peek;
With your code like this:
You can peek into the stream by changing it to look like this (with child process piping sample):
var ps = ;;
PeekStream inherits from Stream and supports basic read and write operation.
In addition, PeekStream exports a
window property that is a
Buffer of the data that has
been filtered. When source stream emits
data the data is appended to the end of the
and any excess from the configured size is trimmed from the beginning of the buffer.
require('peekstream').peek( SRC, [DEST], [SIZE] )
Creates and return a new PeekStream class instance with
SRC stream piped through it.
DEST stream is specified, the returned PeekStream will be piped
through the destination stream automatically as well.
DEST is also accessible from the resulting stream via the
destination property respectively.
new require('peekstream').PeekStream( [SIZE] )
PeekStream with specified windowing size (defaults to 1 kiB)
CONTRIBUTE / DEVELOP / EXTEND
make testmake tdd # spins a loop
Compiles to JS with
Something to do:
- Make PeekStream a two-way stream supporting cases where user wants to pipes the destination stream back into the source stream as well.
- Returns the destination stream so it is more compatible with how
pipe()works (but then how do we returned the PeekStream instance?)
- Better handling of back-pressure. (Now just always returns true since we don't buffer in the traditional sense.)