vendredi 20 février 2015

Node.JS - How to stop a piped stream conditionally

I'm a newbee to java-script & nodejs...


I have a file processing-stream which is composed of multiple streams pipped together. Works great...I'd like to enhance this by conditionally stopping the stream from processing and reading when a threshold has been reached.



inputStream.
pipe(unzip()).
pipe(latin1Decoder).
pipe(
combine(
through(function(obj){
//part-1 -
this.push(obj);
}),
through(function(obj){
//part-2-
this.push(obj);
})
));


In part-1 if I do this.push(null) then the combiner will ignore incoming input.


However, I can't stop reading the file. That's annoying because the file is pretty huge.


What is the best way for me to access the input stream from inside the pipe-line to close it?


Aucun commentaire:

Enregistrer un commentaire