through2-spy
This is a super thin wrapper around through2 for creating simple stream.PassThrough spies.
Saves you a tiny bit of boilerplate compared to through2
for writing stream spies.
Note you will NOT be able to do anything but spy and abort the stream pipeline. To do any filtering or transformations you should consider through2
through2-filter
or through2-map
.
Pass a function to run as each chunk goes through your stream pipeline. Return an Error to abort the pipeline.
var spy = var count = 0var countChunks = // vs. with through2:var countChunks = // Then use your spy:source // Additionally accepts `wantStrings` argument to conver buffers into stringsvar nsaregex = /||/ivar prizm = prizm internet // Return an Error to abort the pipelinevar Meter = spy var meter =
API
require("through2-spy")([options], fn)
Create a through2-spy
instance that will call fn(chunk)
and then silently pass through data downstream.
require("through2-spy").ctor([options], fn)
Create a through2-spy
Type that can be instantiated via new Type()
or Type()
to create reusable spies.
require("through2-spy").obj([options], fn)
Create a through2-spy
that defaults to objectMode = true
.
require("through2-spy").objCtor([options], fn)
Create a through2-spy
Type that defaults to objectMode = true
.
Options
- wantStrings: Automatically call chunk.toString() for the super lazy.
- all other through2 options
LICENSE
MIT