diff options
Diffstat (limited to 'node_modules/readable-stream/lib/_stream_transform.js')
-rw-r--r-- | node_modules/readable-stream/lib/_stream_transform.js | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/node_modules/readable-stream/lib/_stream_transform.js b/node_modules/readable-stream/lib/_stream_transform.js index cd2583207..625cdc176 100644 --- a/node_modules/readable-stream/lib/_stream_transform.js +++ b/node_modules/readable-stream/lib/_stream_transform.js @@ -94,6 +94,7 @@ function Transform(options) { this._transformState = new TransformState(this); + // when the writable side finishes, then flush out anything remaining. var stream = this; // start out asking for a readable event once data is transformed. @@ -110,10 +111,9 @@ function Transform(options) { if (typeof options.flush === 'function') this._flush = options.flush; } - // When the writable side finishes, then flush out anything remaining. this.once('prefinish', function () { - if (typeof this._flush === 'function') this._flush(function (er, data) { - done(stream, er, data); + if (typeof this._flush === 'function') this._flush(function (er) { + done(stream, er); });else done(stream); }); } @@ -134,7 +134,7 @@ Transform.prototype.push = function (chunk, encoding) { // an error, then that'll put the hurt on the whole operation. If you // never call cb(), then you'll never get another chunk. Transform.prototype._transform = function (chunk, encoding, cb) { - throw new Error('_transform() is not implemented'); + throw new Error('not implemented'); }; Transform.prototype._write = function (chunk, encoding, cb) { @@ -164,19 +164,17 @@ Transform.prototype._read = function (n) { } }; -function done(stream, er, data) { +function done(stream, er) { if (er) return stream.emit('error', er); - if (data !== null && data !== undefined) stream.push(data); - // if there's nothing in the write buffer, then that means // that nothing more will ever be provided var ws = stream._writableState; var ts = stream._transformState; - if (ws.length) throw new Error('Calling transform done when ws.length != 0'); + if (ws.length) throw new Error('calling transform done when ws.length != 0'); - if (ts.transforming) throw new Error('Calling transform done when still transforming'); + if (ts.transforming) throw new Error('calling transform done when still transforming'); return stream.push(null); }
\ No newline at end of file |