tap-stream
Taps a nodejs stream and logs the data that's coming through.
npm install tap-stream
Given an object stream we can print out objects passing through and control the detail via the depth parameter:
;
;
objectStream().pipe(tap(2));
For even more control a custom log function may be supplied:
;
Bird: yellow rumped warbler, id: 0, age: 1, layed egg: trueBird: yellow rumped warbler, id: 1, age: 1, layed egg: true
API
tap( [ depth | log ] )
Intercepts the stream and logs data that is passing through.
-
optional parameter is either a
Number
or aFunction
-
if no parameter is given,
depth
defaults to0
andlog
toconsole.log(util.inspect(..))
-
depth
controls thedepth
with which util.inspect is called -
log
replaces the default logging function with a custom one
Example:
var tap = ; myStream // log intermediate results // continute manipulating the data
Object stream
Included in order to give context for above examples.
{ var s = objects = 0; var iv = ; return s;}