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