Skip to content

Commit c65f92d

Browse files
committed
stream: remove whitespace changes
1 parent 753cfc2 commit c65f92d

File tree

1 file changed

+31
-30
lines changed

1 file changed

+31
-30
lines changed

lib/internal/streams/readable.js

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,6 @@ function ReadableState(options, stream, isDuplex) {
183183
this.state |= kObjectMode;
184184
stream.push = readableAddChunkPushObjectMode;
185185
stream.unshift = readableAddChunkUnshiftObjectMode;
186-
187186
} else {
188187
this.state &= ~kObjectMode;
189188
stream.push = readableAddChunkPushByteMode;
@@ -290,14 +289,16 @@ function Readable(options) {
290289
}
291290
});
292291

292+
const isObjectMode = this._readableState.objectMode;
293+
293294
// Manually shove something into the read() buffer.
294295
// This returns true if the highWaterMark has not been hit yet,
295296
// similar to how Writable.write() returns true if you should
296297
// write() some more.
297-
this.push = this._readableState.objectMode ? readableAddChunkPushObjectMode : readableAddChunkPushByteMode;
298+
this.push = isObjectMode ? readableAddChunkPushObjectMode : readableAddChunkPushByteMode;
298299

299300
// Unshift should *always* be something directly out of read().
300-
this.unshift = this._readableState.objectMode ? readableAddChunkUnshiftObjectMode : readableAddChunkUnshiftByteMode;
301+
this.unshift = isObjectMode ? readableAddChunkUnshiftObjectMode : readableAddChunkUnshiftByteMode;
301302
}
302303

303304
Readable.prototype.destroy = destroyImpl.destroy;
@@ -478,12 +479,12 @@ function canPushMore(state) {
478479
// Also, if we have no data yet, we can stand some more bytes.
479480
// This is to work around cases where hwm=0, such as the repl.
480481
return !state.ended &&
481-
(state.length < state.highWaterMark || state.length === 0);
482+
(state.length < state.highWaterMark || state.length === 0);
482483
}
483484

484485
function addChunk(stream, state, chunk, addToFront) {
485486
if (state.flowing && state.length === 0 && !state.sync &&
486-
stream.listenerCount('data') > 0) {
487+
stream.listenerCount('data') > 0) {
487488
// Use the guard to avoid creating `Set()` repeatedly
488489
// when we have multiple pipes.
489490
if ((state.state & kMultiAwaitDrain) !== 0) {
@@ -594,11 +595,11 @@ Readable.prototype.read = function(n) {
594595
// already have a bunch of data in the buffer, then just trigger
595596
// the 'readable' event and move on.
596597
if (n === 0 &&
597-
state.needReadable &&
598-
((state.highWaterMark !== 0 ?
599-
state.length >= state.highWaterMark :
600-
state.length > 0) ||
601-
state.ended)) {
598+
state.needReadable &&
599+
((state.highWaterMark !== 0 ?
600+
state.length >= state.highWaterMark :
601+
state.length > 0) ||
602+
state.ended)) {
602603
debug('read: emitReadable', state.length, state.ended);
603604
if (state.length === 0 && state.ended)
604605
endReadable(this);
@@ -652,7 +653,7 @@ Readable.prototype.read = function(n) {
652653
// reading, then it's unnecessary, if we're constructing we have to wait,
653654
// and if we're destroyed or errored, then it's not allowed,
654655
if (state.ended || state.reading || state.destroyed || state.errored ||
655-
!state.constructed) {
656+
!state.constructed) {
656657
doRead = false;
657658
debug('reading, ended or constructing', doRead);
658659
} else if (doRead) {
@@ -769,9 +770,9 @@ function emitReadable_(stream) {
769770
// 3. It is below the highWaterMark, so we can schedule
770771
// another readable later.
771772
state.needReadable =
772-
!state.flowing &&
773-
!state.ended &&
774-
state.length <= state.highWaterMark;
773+
!state.flowing &&
774+
!state.ended &&
775+
state.length <= state.highWaterMark;
775776
flow(stream);
776777
}
777778

@@ -814,13 +815,13 @@ function maybeReadMore_(stream, state) {
814815
// read()s. The execution ends in this method again after the _read() ends
815816
// up calling push() with more data.
816817
while (!state.reading && !state.ended &&
817-
(state.length < state.highWaterMark ||
818-
(state.flowing && state.length === 0))) {
818+
(state.length < state.highWaterMark ||
819+
(state.flowing && state.length === 0))) {
819820
const len = state.length;
820821
debug('maybeReadMore read 0');
821822
stream.read(0);
822823
if (len === state.length)
823-
// Didn't get any data, stop spinning.
824+
// Didn't get any data, stop spinning.
824825
break;
825826
}
826827
state.readingMore = false;
@@ -851,8 +852,8 @@ Readable.prototype.pipe = function(dest, pipeOpts) {
851852
debug('pipe count=%d opts=%j', state.pipes.length, pipeOpts);
852853

853854
const doEnd = (!pipeOpts || pipeOpts.end !== false) &&
854-
dest !== process.stdout &&
855-
dest !== process.stderr;
855+
dest !== process.stdout &&
856+
dest !== process.stderr;
856857

857858
const endFn = doEnd ? onend : unpipe;
858859
if (state.endEmitted)
@@ -901,7 +902,7 @@ Readable.prototype.pipe = function(dest, pipeOpts) {
901902
// So, if this is awaiting a drain, then we just call it now.
902903
// If we don't know, then assume that we are waiting for one.
903904
if (ondrain && state.awaitDrainWriters &&
904-
(!dest._writableState || dest._writableState.needDrain))
905+
(!dest._writableState || dest._writableState.needDrain))
905906
ondrain();
906907
}
907908

@@ -1010,7 +1011,7 @@ function pipeOnDrain(src, dest) {
10101011
}
10111012

10121013
if ((!state.awaitDrainWriters || state.awaitDrainWriters.size === 0) &&
1013-
src.listenerCount('data')) {
1014+
src.listenerCount('data')) {
10141015
src.resume();
10151016
}
10161017
};
@@ -1305,7 +1306,7 @@ async function* createAsyncIterator(stream, options) {
13051306
} finally {
13061307
if (
13071308
(error || options?.destroyOnReturn !== false) &&
1308-
(error === undefined || stream._readableState.autoDestroy)
1309+
(error === undefined || stream._readableState.autoDestroy)
13091310
) {
13101311
destroyImpl.destroyer(stream, null);
13111312
} else {
@@ -1328,7 +1329,7 @@ ObjectDefineProperties(Readable.prototype, {
13281329
// Compat. The user might manually disable readable side through
13291330
// deprecated setter.
13301331
return !!r && r.readable !== false && !r.destroyed && !r.errorEmitted &&
1331-
!r.endEmitted;
1332+
!r.endEmitted;
13321333
},
13331334
set(val) {
13341335
// Backwards compat.
@@ -1352,8 +1353,8 @@ ObjectDefineProperties(Readable.prototype, {
13521353
get: function() {
13531354
return !!(
13541355
this._readableState.readable !== false &&
1355-
(this._readableState.destroyed || this._readableState.errored) &&
1356-
!this._readableState.endEmitted
1356+
(this._readableState.destroyed || this._readableState.errored) &&
1357+
!this._readableState.endEmitted
13571358
);
13581359
},
13591360
},
@@ -1523,7 +1524,7 @@ function endReadableNT(state, stream) {
15231524

15241525
// Check that we didn't get one last unshift.
15251526
if (!state.errored && !state.closeEmitted &&
1526-
!state.endEmitted && state.length === 0) {
1527+
!state.endEmitted && state.length === 0) {
15271528
state.endEmitted = true;
15281529
stream.emit('end');
15291530

@@ -1535,9 +1536,9 @@ function endReadableNT(state, stream) {
15351536
const wState = stream._writableState;
15361537
const autoDestroy = !wState || (
15371538
wState.autoDestroy &&
1538-
// We don't expect the writable to ever 'finish'
1539-
// if writable is explicitly set to false.
1540-
(wState.finished || wState.writable === false)
1539+
// We don't expect the writable to ever 'finish'
1540+
// if writable is explicitly set to false.
1541+
(wState.finished || wState.writable === false)
15411542
);
15421543

15431544
if (autoDestroy) {
@@ -1549,7 +1550,7 @@ function endReadableNT(state, stream) {
15491550

15501551
function endWritableNT(stream) {
15511552
const writable = stream.writable && !stream.writableEnded &&
1552-
!stream.destroyed;
1553+
!stream.destroyed;
15531554
if (writable) {
15541555
stream.end();
15551556
}

0 commit comments

Comments
 (0)