length-stream - Simple pass-through stream (RW) which accumulates the length of the stream (streams2)
Simple pass-through stream (RW) which accumulates the length of the stream.
npm install length-stream
If you provide a lengthListener when you construct the stream, it will be called with the resultant length of the stream just prior to end being emitted.
lengthStream(lengthListener)- constructs a new stream instance, lengthListener will be called prior to the
endevent being emitted
lengthListenerfunction signature is
var lengthStream = require'length-stream';var resultLength;resultLength = length;var lstream = lengthStreamlengthListener; // create instance, lengthListener will get lengthreadstreampipelstream // length calculated as it passes throughpipe
I find that when I am accumulating stream data, that I often need the resultant length, so rather than write the code over and over again to do that, this simple stream can be piped through and it will provide the resultant length when the stream ends by calling
If you have input or ideas or would like to get involved, you may: