summaryrefslogtreecommitdiff
path: root/lib/_stream_transform.js
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2013-02-22 16:45:22 -0800
committerisaacs <i@izs.me>2013-02-25 07:38:10 -0800
commite03bc472f0b4a50ede3a0e0be7de9e5d12bb85a9 (patch)
tree72fa17b05d44aaf74835a5fe6bb101bd8205b82a /lib/_stream_transform.js
parent4231dab39f8d3769196fefede15e048f3ca09300 (diff)
downloadnode-e03bc472f0b4a50ede3a0e0be7de9e5d12bb85a9.tar.gz
stream: Start out in sync=true state
The Readable and Writable classes will nextTick certain things if in sync mode. The sync flag gets unset after a call to _read or _write. However, most of these behaviors should also be deferred until nextTick if no reads have been made (for example, the automatic '_read up to hwm' behavior on Readable.push(chunk)) Set the sync flag to true in the constructor, so that it will not trigger an immediate 'readable' event, call to _read, before the user has had a chance to set a _read method implementation.
Diffstat (limited to 'lib/_stream_transform.js')
-rw-r--r--lib/_stream_transform.js5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/_stream_transform.js b/lib/_stream_transform.js
index b83fedb62..0ee5a5030 100644
--- a/lib/_stream_transform.js
+++ b/lib/_stream_transform.js
@@ -125,6 +125,11 @@ function Transform(options) {
// start out asking for a readable event once data is transformed.
this._readableState.needReadable = true;
+ // we have implemented the _read method, and done the other things
+ // that Readable wants before the first _read call, so unset the
+ // sync guard flag.
+ this._readableState.sync = false;
+
this.once('finish', function() {
if ('function' === typeof this._flush)
this._flush(ts.output, function(er) {