Package Exports
- peekstream
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (peekstream) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
PEEK-A-BOO !
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 peekstreamvar peek = require('peekstream').peek;EXAMPLE
With your code like this:
child.stdout.pipe(process.stdout);You can peek into the stream by changing it to look like this (with child process piping sample):
var ps = peek(child.stdout, process.stdout);
setInterval(function monitorStreamContent() {
console.log("PIPE: " + ps.window.toString());
}, 1000);API
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 window
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.
Additionallty, if DEST stream is specified, the returned PeekStream will be piped
through the destination stream automatically as well.
SRC and DEST is also accessible from the resulting stream via the source and
destination property respectively.
new require('peekstream').PeekStream( [SIZE] )
Creates a PeekStream with specified windowing size (defaults to 1 kiB)
LICENSE
BSD
CONTRIBUTE / DEVELOP / EXTEND
Test with
make test
make tdd # spins a loopCompiles to JS with
make allSomething 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.)
