@@ -589,11 +589,9 @@ In classes that extend the Transform class, make sure to call the
589
589
constructor so that the buffering settings can be properly
590
590
initialized.
591
591
592
- ### transform.\_ transform(chunk, outputFn, callback)
592
+ ### transform.\_ transform(chunk, callback)
593
593
594
594
* ` chunk` {Buffer} The chunk to be transformed.
595
- * ` outputFn` {Function} Call this function with any output data to be
596
- passed to the readable interface.
597
595
* ` callback` {Function} Call this function (optionally with an error
598
596
argument) when you are done processing the supplied chunk.
599
597
@@ -609,20 +607,21 @@ Transform class, to handle the bytes being written, and pass them off
609
607
to the readable portion of the interface. Do asynchronous I/O,
610
608
process things, and so on.
611
609
610
+ Call ` transform .push (outputChunk)` 0 or more times to generate output
611
+ from this input chunk, depending on how much data you want to output
612
+ as a result of this chunk.
613
+
612
614
Call the callback function only when the current chunk is completely
613
- consumed. Note that this may mean that you call the ` outputFn` zero
614
- or more times, depending on how much data you want to output as a
615
- result of this chunk.
615
+ consumed. Note that there may or may not be output as a result of any
616
+ particular input chunk.
616
617
617
618
This method is prefixed with an underscore because it is internal to
618
619
the class that defines it, and should not be called directly by user
619
620
programs. However, you **are** expected to override this method in
620
621
your own extension classes.
621
622
622
- ### transform.\_ flush(outputFn, callback)
623
+ ### transform.\_ flush(callback)
623
624
624
- * ` outputFn` {Function} Call this function with any output data to be
625
- passed to the readable interface.
626
625
* ` callback` {Function} Call this function (optionally with an error
627
626
argument) when you are done flushing any remaining data.
628
627
@@ -639,8 +638,9 @@ can with what is left, so that the data will be complete.
639
638
In those cases, you can implement a ` _flush` method, which will be
640
639
called at the very end, after all the written data is consumed, but
641
640
before emitting ` end` to signal the end of the readable side. Just
642
- like with ` _transform` , call ` outputFn` zero or more times, as
643
- appropriate, and call ` callback` when the flush operation is complete.
641
+ like with ` _transform` , call ` transform .push (chunk)` zero or more
642
+ times, as appropriate, and call ` callback` when the flush operation is
643
+ complete.
644
644
645
645
This method is prefixed with an underscore because it is internal to
646
646
the class that defines it, and should not be called directly by user
@@ -671,7 +671,7 @@ function SimpleProtocol(options) {
671
671
SimpleProtocol .prototype = Object .create (
672
672
Transform .prototype , { constructor : { value: SimpleProtocol }});
673
673
674
- SimpleProtocol.prototype._transform = function(chunk, output, done) {
674
+ SimpleProtocol.prototype._transform = function(chunk, done) {
675
675
if (! this ._inBody ) {
676
676
// check if the chunk has a \n\n
677
677
var split = - 1 ;
@@ -707,11 +707,11 @@ SimpleProtocol.prototype._transform = function(chunk, output, done) {
707
707
this .emit (' header' , this .header );
708
708
709
709
// now, because we got some extra data, emit this first.
710
- output (b);
710
+ this . push (b);
711
711
}
712
712
} else {
713
713
// from there on, just provide the data to our consumer as-is.
714
- output (b);
714
+ this . push (b);
715
715
}
716
716
done ();
717
717
};
0 commit comments