stream: change default hwm for objectMode to 16
This commit is contained in:
Родитель
ee695e935d
Коммит
ba72570eae
|
@ -871,7 +871,7 @@ SimpleProtocol.prototype._read = function(n) {
|
|||
* `options` {Object}
|
||||
* `highWaterMark` {Number} The maximum number of bytes to store in
|
||||
the internal buffer before ceasing to read from the underlying
|
||||
resource. Default=16kb
|
||||
resource. Default=16kb, or 16 for `objectMode` streams
|
||||
* `encoding` {String} If specified, then buffers will be decoded to
|
||||
strings using the specified encoding. Default=null
|
||||
* `objectMode` {Boolean} Whether this stream should behave
|
||||
|
@ -987,7 +987,7 @@ how to implement Writable streams in your programs.
|
|||
|
||||
* `options` {Object}
|
||||
* `highWaterMark` {Number} Buffer level when [`write()`][] starts
|
||||
returning false. Default=16kb
|
||||
returning false. Default=16kb, or 16 for `objectMode` streams
|
||||
* `decodeStrings` {Boolean} Whether or not to decode strings into
|
||||
Buffers before passing them to [`_write()`][]. Default=true
|
||||
|
||||
|
|
|
@ -36,7 +36,8 @@ function ReadableState(options, stream) {
|
|||
// the point at which it stops calling _read() to fill the buffer
|
||||
// Note: 0 is a valid value, means "don't call _read preemptively ever"
|
||||
var hwm = options.highWaterMark;
|
||||
this.highWaterMark = (hwm || hwm === 0) ? hwm : 16 * 1024;
|
||||
var defaultHwm = options.objectMode ? 16 : 16 * 1024;
|
||||
this.highWaterMark = (hwm || hwm === 0) ? hwm : defaultHwm;
|
||||
|
||||
// cast to ints.
|
||||
this.highWaterMark = ~~this.highWaterMark;
|
||||
|
|
|
@ -44,7 +44,8 @@ function WritableState(options, stream) {
|
|||
// 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;
|
||||
var defaultHwm = options.objectMode ? 16 : 16 * 1024;
|
||||
this.highWaterMark = (hwm || hwm === 0) ? hwm : defaultHwm;
|
||||
|
||||
// object stream flag to indicate whether or not this stream
|
||||
// contains buffers or objects.
|
||||
|
|
Загрузка…
Ссылка в новой задаче