Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions lib/_stream_readable.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function ReadableState(options, stream) {
// However, some cases require setting options to different
// values for the readable and the writable sides of the duplex stream.
// These options can be provided separately as readableXXX and writableXXX.
var isDuplex = stream instanceof Stream.Duplex;
const isDuplex = stream instanceof Stream.Duplex;

// object stream flag. Used to make read(n) ignore n and to
// make all the buffer merging and length checks go away
Expand All @@ -77,19 +77,15 @@ 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;
var readableHwm = options.readableHighWaterMark;
var defaultHwm = this.objectMode ? 16 : 16 * 1024;
const hwm = options.highWaterMark;
const readableHwm = options.readableHighWaterMark;

if (hwm || hwm === 0)
this.highWaterMark = hwm;
this.highWaterMark = Math.floor(hwm);
else if (isDuplex && (readableHwm || readableHwm === 0))
this.highWaterMark = readableHwm;
this.highWaterMark = Math.floor(readableHwm);
else
this.highWaterMark = defaultHwm;

// cast to ints.
this.highWaterMark = Math.floor(this.highWaterMark);
this.highWaterMark = this.objectMode ? 16 : 16 * 1024;

// A linked list is used to store data chunks instead of an array because the
// linked list can remove elements from the beginning faster than
Expand Down
20 changes: 8 additions & 12 deletions lib/_stream_writable.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function WritableState(options, stream) {
// However, some cases require setting options to different
// values for the readable and the writable sides of the duplex stream.
// These options can be provided separately as readableXXX and writableXXX.
var isDuplex = stream instanceof Stream.Duplex;
const isDuplex = stream instanceof Stream.Duplex;

// object stream flag to indicate whether or not this stream
// contains buffers or objects.
Expand All @@ -58,19 +58,15 @@ function WritableState(options, stream) {
// the point at which write() starts returning false
// 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;
var writableHwm = options.writableHighWaterMark;
var defaultHwm = this.objectMode ? 16 : 16 * 1024;
const hwm = options.highWaterMark;
const writableHwm = options.writableHighWaterMark;

if (hwm || hwm === 0)
this.highWaterMark = hwm;
this.highWaterMark = Math.floor(hwm);
else if (isDuplex && (writableHwm || writableHwm === 0))
this.highWaterMark = writableHwm;
this.highWaterMark = Math.floor(writableHwm);
else
this.highWaterMark = defaultHwm;

// cast to ints.
this.highWaterMark = Math.floor(this.highWaterMark);
this.highWaterMark = this.objectMode ? 16 : 16 * 1024;

// if _final has been called
this.finalCalled = false;
Expand All @@ -90,7 +86,7 @@ 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.
var noDecode = options.decodeStrings === false;
const noDecode = options.decodeStrings === false;
this.decodeStrings = !noDecode;

// Crypto is kind of old and crusty. Historically, its default string
Expand Down Expand Up @@ -148,7 +144,7 @@ function WritableState(options, stream) {

// allocate the first CorkedRequest, there is always
// one allocated and free to use, and we maintain at most two
var corkReq = { next: null, entry: null, finish: undefined };
const corkReq = { next: null, entry: null, finish: undefined };
corkReq.finish = onCorkedFinish.bind(undefined, corkReq, this);
this.corkedRequestsFree = corkReq;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ Buffer.compare = function compare(a, b) {

Buffer.isEncoding = function isEncoding(encoding) {
return typeof encoding === 'string' &&
typeof normalizeEncoding(encoding) === 'string';
normalizeEncoding(encoding) !== undefined;
};
Buffer[kIsEncodingSymbol] = Buffer.isEncoding;

Expand All @@ -465,7 +465,7 @@ Buffer.concat = function concat(list, length) {
length = length >>> 0;
}

var buffer = Buffer.allocUnsafe(length);
const buffer = Buffer.allocUnsafe(length);
var pos = 0;
for (i = 0; i < list.length; i++) {
var buf = list[i];
Expand Down
Loading