Hey,
I'm trying to create a streaming parser/transformer for a special web proxy project. The 'streams2' stream.Transform base class makes this quite easy, but trying to benchmark some thing I've hit a problem: it seems no (end) events are emitted.
The docs don't list any events under this class explicitly, but one would imagine the events from the stream.Readable and stream.Writable are also implemented in stream.Transform.
My question: Am I doing something wrong, is this by design, or could this be considered a bug?
Al I could find on the subject is this
Stack Overflow question +
comment
Code (more or less):
stream = require('stream');
function Parser (options) {
if (!(this instanceof Parser)) return new Parser(options);
stream.Transform.call(this, options);
this.options = options || {};
}
util.inherits(Parser, stream.Transform);
Parser.prototype._transform = function(chunk, encoding, done) {
// magic stuff that transforms chunk
this.push(chunk);
done();
};
parser = new Parser();
parser.on('end', function () {
console.log('This will never happen ???');
});
req.pipe(parser, {end: false}).pipe(res);