|
|
@ -36,22 +36,18 @@ function WritableState(options, stream) { |
|
|
|
options = options || {}; |
|
|
|
|
|
|
|
// the point at which write() starts returning false
|
|
|
|
this.highWaterMark = options.hasOwnProperty('highWaterMark') ? |
|
|
|
options.highWaterMark : 16 * 1024; |
|
|
|
// Note: 0 is a valid value, means that we always return false if
|
|
|
|
// the entire buffer is not flushed immediately on write()
|
|
|
|
var hwm = options.highWaterMark; |
|
|
|
this.highWaterMark = (hwm || hwm === 0) ? hwm : 16 * 1024; |
|
|
|
|
|
|
|
// the point that it has to get to before we call _write(chunk,cb)
|
|
|
|
// default to pushing everything out as fast as possible.
|
|
|
|
this.lowWaterMark = options.hasOwnProperty('lowWaterMark') ? |
|
|
|
options.lowWaterMark : 0; |
|
|
|
this.lowWaterMark = options.lowWaterMark || 0; |
|
|
|
|
|
|
|
// cast to ints.
|
|
|
|
assert(typeof this.lowWaterMark === 'number'); |
|
|
|
assert(typeof this.highWaterMark === 'number'); |
|
|
|
this.lowWaterMark = ~~this.lowWaterMark; |
|
|
|
this.highWaterMark = ~~this.highWaterMark; |
|
|
|
assert(this.lowWaterMark >= 0); |
|
|
|
assert(this.highWaterMark >= this.lowWaterMark, |
|
|
|
this.highWaterMark + '>=' + this.lowWaterMark); |
|
|
|
|
|
|
|
this.needDrain = false; |
|
|
|
// at the start of calling end()
|
|
|
@ -66,8 +62,8 @@ function WritableState(options, stream) { |
|
|
|
// should we decode strings into buffers before passing to _write?
|
|
|
|
// this is here so that some node-core streams can optimize string
|
|
|
|
// handling at a lower level.
|
|
|
|
this.decodeStrings = options.hasOwnProperty('decodeStrings') ? |
|
|
|
options.decodeStrings : true; |
|
|
|
var noDecode = options.decodeStrings === false; |
|
|
|
this.decodeStrings = !noDecode; |
|
|
|
|
|
|
|
// not an actual buffer we keep track of, but a measurement
|
|
|
|
// of how much we're waiting to get pushed to some underlying
|
|
|
|