Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/readable-stream/lib/_stream_transform.js')
-rw-r--r--deps/npm/node_modules/readable-stream/lib/_stream_transform.js59
1 files changed, 21 insertions, 38 deletions
diff --git a/deps/npm/node_modules/readable-stream/lib/_stream_transform.js b/deps/npm/node_modules/readable-stream/lib/_stream_transform.js
index 3675d18d915..625cdc17698 100644
--- a/deps/npm/node_modules/readable-stream/lib/_stream_transform.js
+++ b/deps/npm/node_modules/readable-stream/lib/_stream_transform.js
@@ -53,9 +53,8 @@ util.inherits = require('inherits');
util.inherits(Transform, Duplex);
-
function TransformState(stream) {
- this.afterTransform = function(er, data) {
+ this.afterTransform = function (er, data) {
return afterTransform(stream, er, data);
};
@@ -63,6 +62,7 @@ function TransformState(stream) {
this.transforming = false;
this.writecb = null;
this.writechunk = null;
+ this.writeencoding = null;
}
function afterTransform(stream, er, data) {
@@ -71,17 +71,14 @@ function afterTransform(stream, er, data) {
var cb = ts.writecb;
- if (!cb)
- return stream.emit('error', new Error('no writecb in Transform class'));
+ if (!cb) return stream.emit('error', new Error('no writecb in Transform class'));
ts.writechunk = null;
ts.writecb = null;
- if (data !== null && data !== undefined)
- stream.push(data);
+ if (data !== null && data !== undefined) stream.push(data);
- if (cb)
- cb(er);
+ cb(er);
var rs = stream._readableState;
rs.reading = false;
@@ -90,10 +87,8 @@ function afterTransform(stream, er, data) {
}
}
-
function Transform(options) {
- if (!(this instanceof Transform))
- return new Transform(options);
+ if (!(this instanceof Transform)) return new Transform(options);
Duplex.call(this, options);
@@ -111,24 +106,19 @@ function Transform(options) {
this._readableState.sync = false;
if (options) {
- if (typeof options.transform === 'function')
- this._transform = options.transform;
+ if (typeof options.transform === 'function') this._transform = options.transform;
- if (typeof options.flush === 'function')
- this._flush = options.flush;
+ if (typeof options.flush === 'function') this._flush = options.flush;
}
- this.once('prefinish', function() {
- if (typeof this._flush === 'function')
- this._flush(function(er) {
- done(stream, er);
- });
- else
- done(stream);
+ this.once('prefinish', function () {
+ if (typeof this._flush === 'function') this._flush(function (er) {
+ done(stream, er);
+ });else done(stream);
});
}
-Transform.prototype.push = function(chunk, encoding) {
+Transform.prototype.push = function (chunk, encoding) {
this._transformState.needTransform = false;
return Duplex.prototype.push.call(this, chunk, encoding);
};
@@ -143,28 +133,25 @@ Transform.prototype.push = function(chunk, encoding) {
// Call `cb(err)` when you are done with this chunk. If you pass
// 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) {
+Transform.prototype._transform = function (chunk, encoding, cb) {
throw new Error('not implemented');
};
-Transform.prototype._write = function(chunk, encoding, cb) {
+Transform.prototype._write = function (chunk, encoding, cb) {
var ts = this._transformState;
ts.writecb = cb;
ts.writechunk = chunk;
ts.writeencoding = encoding;
if (!ts.transforming) {
var rs = this._readableState;
- if (ts.needTransform ||
- rs.needReadable ||
- rs.length < rs.highWaterMark)
- this._read(rs.highWaterMark);
+ if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
}
};
// Doesn't matter what the args are here.
// _transform does all the work.
// That we got here means that the readable side wants more data.
-Transform.prototype._read = function(n) {
+Transform.prototype._read = function (n) {
var ts = this._transformState;
if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
@@ -177,21 +164,17 @@ Transform.prototype._read = function(n) {
}
};
-
function done(stream, er) {
- if (er)
- return stream.emit('error', er);
+ if (er) return stream.emit('error', er);
// 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