@@ -94,7 +94,7 @@ function ReadableState(options, stream, isDuplex) {
9494 isDuplex = stream instanceof Stream . Duplex ;
9595
9696 // Object stream flag. Used to make read(n) ignore n and to
97- // make all the buffer merging and length checks go away
97+ // make all the buffer merging and length checks go away.
9898 this . objectMode = ! ! ( options && options . objectMode ) ;
9999
100100 if ( isDuplex )
@@ -109,7 +109,7 @@ function ReadableState(options, stream, isDuplex) {
109109
110110 // A linked list is used to store data chunks instead of an array because the
111111 // linked list can remove elements from the beginning faster than
112- // array.shift()
112+ // array.shift().
113113 this . buffer = new BufferList ( ) ;
114114 this . length = 0 ;
115115 this . pipes = [ ] ;
@@ -132,16 +132,16 @@ function ReadableState(options, stream, isDuplex) {
132132 this . resumeScheduled = false ;
133133 this [ kPaused ] = null ;
134134
135- // True if the error was already emitted and should not be thrown again
135+ // True if the error was already emitted and should not be thrown again.
136136 this . errorEmitted = false ;
137137
138138 // Should close be emitted on destroy. Defaults to true.
139139 this . emitClose = ! options || options . emitClose !== false ;
140140
141- // Should .destroy() be called after 'end' (and potentially 'finish')
141+ // Should .destroy() be called after 'end' (and potentially 'finish').
142142 this . autoDestroy = ! options || options . autoDestroy !== false ;
143143
144- // Has it been destroyed
144+ // Has it been destroyed.
145145 this . destroyed = false ;
146146
147147 // Indicates whether the stream has errored. When true no further
@@ -159,11 +159,11 @@ function ReadableState(options, stream, isDuplex) {
159159 this . defaultEncoding = ( options && options . defaultEncoding ) || 'utf8' ;
160160
161161 // Ref the piped dest which we need a drain event on it
162- // type: null | Writable | Set<Writable>
162+ // type: null | Writable | Set<Writable>.
163163 this . awaitDrainWriters = null ;
164164 this . multiAwaitDrain = false ;
165165
166- // If true, a maybeReadMore has been scheduled
166+ // If true, a maybeReadMore has been scheduled.
167167 this . readingMore = false ;
168168
169169 this . decoder = null ;
@@ -182,7 +182,7 @@ function Readable(options) {
182182 return new Readable ( options ) ;
183183
184184 // Checking for a Stream.Duplex instance is faster here instead of inside
185- // the ReadableState constructor, at least with V8 6.5
185+ // the ReadableState constructor, at least with V8 6.5.
186186 const isDuplex = this instanceof Stream . Duplex ;
187187
188188 this . _readableState = new ReadableState ( options , this , isDuplex ) ;
@@ -216,7 +216,7 @@ Readable.prototype.push = function(chunk, encoding) {
216216 return readableAddChunk ( this , chunk , encoding , false ) ;
217217} ;
218218
219- // Unshift should *always* be something directly out of read()
219+ // Unshift should *always* be something directly out of read().
220220Readable . prototype . unshift = function ( chunk , encoding ) {
221221 return readableAddChunk ( this , chunk , encoding , true ) ;
222222} ;
@@ -231,7 +231,7 @@ function readableAddChunk(stream, chunk, encoding, addToFront) {
231231 encoding = encoding || state . defaultEncoding ;
232232 if ( addToFront && state . encoding && state . encoding !== encoding ) {
233233 // When unshifting, if state.encoding is set, we have to save
234- // the string in the BufferList with the state encoding
234+ // the string in the BufferList with the state encoding.
235235 chunk = Buffer . from ( chunk , encoding ) . toString ( state . encoding ) ;
236236 } else if ( encoding !== state . encoding ) {
237237 chunk = Buffer . from ( chunk , encoding ) ;
@@ -322,7 +322,7 @@ Readable.prototype.setEncoding = function(enc) {
322322 StringDecoder = require ( 'string_decoder' ) . StringDecoder ;
323323 const decoder = new StringDecoder ( enc ) ;
324324 this . _readableState . decoder = decoder ;
325- // If setEncoding(null), decoder.encoding equals utf8
325+ // If setEncoding(null), decoder.encoding equals utf8.
326326 this . _readableState . encoding = this . _readableState . decoder . encoding ;
327327
328328 const buffer = this . _readableState . buffer ;
@@ -338,15 +338,15 @@ Readable.prototype.setEncoding = function(enc) {
338338 return this ;
339339} ;
340340
341- // Don't raise the hwm > 1GB
341+ // Don't raise the hwm > 1GB.
342342const MAX_HWM = 0x40000000 ;
343343function computeNewHighWaterMark ( n ) {
344344 if ( n >= MAX_HWM ) {
345345 // TODO(ronag): Throw ERR_VALUE_OUT_OF_RANGE.
346346 n = MAX_HWM ;
347347 } else {
348348 // Get the next highest power of 2 to prevent increasing hwm excessively in
349- // tiny amounts
349+ // tiny amounts.
350350 n -- ;
351351 n |= n >>> 1 ;
352352 n |= n >>> 2 ;
@@ -366,7 +366,7 @@ function howMuchToRead(n, state) {
366366 if ( state . objectMode )
367367 return 1 ;
368368 if ( NumberIsNaN ( n ) ) {
369- // Only flow one buffer at a time
369+ // Only flow one buffer at a time.
370370 if ( state . flowing && state . length )
371371 return state . buffer . first ( ) . length ;
372372 else
@@ -449,7 +449,7 @@ Readable.prototype.read = function(n) {
449449 let doRead = state . needReadable ;
450450 debug ( 'need readable' , doRead ) ;
451451
452- // If we currently have less than the highWaterMark, then also read some
452+ // If we currently have less than the highWaterMark, then also read some.
453453 if ( state . length === 0 || state . length - n < state . highWaterMark ) {
454454 doRead = true ;
455455 debug ( 'length less than watermark' , doRead ) ;
@@ -527,7 +527,7 @@ function onEofChunk(stream, state) {
527527 if ( state . sync ) {
528528 // If we are sync, wait until next tick to emit the data.
529529 // Otherwise we risk emitting data in the flow()
530- // the readable code triggers during a read() call
530+ // the readable code triggers during a read() call.
531531 emitReadable ( stream ) ;
532532 } else {
533533 // Emit 'readable' now to make sure it gets picked up.
@@ -561,7 +561,7 @@ function emitReadable_(stream) {
561561 state . emittedReadable = false ;
562562 }
563563
564- // The stream needs another readable event if
564+ // The stream needs another readable event if:
565565 // 1. It is not flowing, as the flow mechanism will take
566566 // care of it.
567567 // 2. It is not ended.
@@ -680,7 +680,7 @@ Readable.prototype.pipe = function(dest, pipeOpts) {
680680 let cleanedUp = false ;
681681 function cleanup ( ) {
682682 debug ( 'cleanup' ) ;
683- // Cleanup event handlers once the pipe is broken
683+ // Cleanup event handlers once the pipe is broken.
684684 dest . removeListener ( 'close' , onclose ) ;
685685 dest . removeListener ( 'finish' , onfinish ) ;
686686 if ( ondrain ) {
@@ -774,7 +774,7 @@ Readable.prototype.pipe = function(dest, pipeOpts) {
774774 src . unpipe ( dest ) ;
775775 }
776776
777- // Tell the dest that it's being piped to
777+ // Tell the dest that it's being piped to.
778778 dest . emit ( 'pipe' , src ) ;
779779
780780 // Start the flow if it hasn't been started already.
@@ -844,7 +844,7 @@ Readable.prototype.unpipe = function(dest) {
844844} ;
845845
846846// Set up data events if they are asked for
847- // Ensure readable listeners eventually get something
847+ // Ensure readable listeners eventually get something.
848848Readable . prototype . on = function ( ev , fn ) {
849849 const res = Stream . prototype . on . call ( this , ev , fn ) ;
850850 const state = this . _readableState ;
@@ -854,7 +854,7 @@ Readable.prototype.on = function(ev, fn) {
854854 // a few lines down. This is needed to support once('readable').
855855 state . readableListening = this . listenerCount ( 'readable' ) > 0 ;
856856
857- // Try start flowing on next tick if stream isn't explicitly paused
857+ // Try start flowing on next tick if stream isn't explicitly paused.
858858 if ( state . flowing !== false )
859859 this . resume ( ) ;
860860 } else if ( ev === 'readable' ) {
@@ -917,7 +917,7 @@ function updateReadableListening(self) {
917917 // the upcoming resume will not flow.
918918 state . flowing = true ;
919919
920- // Crude way to check if we should resume
920+ // Crude way to check if we should resume.
921921 } else if ( self . listenerCount ( 'data' ) > 0 ) {
922922 self . resume ( ) ;
923923 } else if ( ! state . readableListening ) {
@@ -938,7 +938,7 @@ Readable.prototype.resume = function() {
938938 debug ( 'resume' ) ;
939939 // We flow only if there is no one listening
940940 // for readable, but we still have to call
941- // resume()
941+ // resume().
942942 state . flowing = ! state . readableListening ;
943943 resume ( this , state ) ;
944944 }
@@ -1006,7 +1006,7 @@ Readable.prototype.wrap = function(stream) {
10061006 if ( state . decoder )
10071007 chunk = state . decoder . write ( chunk ) ;
10081008
1009- // Don't skip over falsy values in objectMode
1009+ // Don't skip over falsy values in objectMode.
10101010 if ( state . objectMode && ( chunk === null || chunk === undefined ) )
10111011 return ;
10121012 else if ( ! state . objectMode && ( ! chunk || ! chunk . length ) )
@@ -1058,7 +1058,7 @@ Readable.prototype[SymbolAsyncIterator] = function() {
10581058
10591059// Making it explicit these properties are not enumerable
10601060// because otherwise some prototype manipulation in
1061- // userland will fail
1061+ // userland will fail.
10621062ObjectDefineProperties ( Readable . prototype , {
10631063 readable : {
10641064 get ( ) {
@@ -1135,13 +1135,13 @@ ObjectDefineProperties(Readable.prototype, {
11351135 } ,
11361136 set ( value ) {
11371137 // We ignore the value if the stream
1138- // has not been initialized yet
1138+ // has not been initialized yet.
11391139 if ( ! this . _readableState ) {
11401140 return ;
11411141 }
11421142
11431143 // Backward compatibility, the user is explicitly
1144- // managing destroyed
1144+ // managing destroyed.
11451145 this . _readableState . destroyed = value ;
11461146 }
11471147 } ,
@@ -1178,15 +1178,15 @@ Readable._fromList = fromList;
11781178// This function is designed to be inlinable, so please take care when making
11791179// changes to the function body.
11801180function fromList ( n , state ) {
1181- // nothing buffered
1181+ // nothing buffered.
11821182 if ( state . length === 0 )
11831183 return null ;
11841184
11851185 let ret ;
11861186 if ( state . objectMode )
11871187 ret = state . buffer . shift ( ) ;
11881188 else if ( ! n || n >= state . length ) {
1189- // Read it all, truncate the list
1189+ // Read it all, truncate the list.
11901190 if ( state . decoder )
11911191 ret = state . buffer . join ( '' ) ;
11921192 else if ( state . buffer . length === 1 )
@@ -1195,7 +1195,7 @@ function fromList(n, state) {
11951195 ret = state . buffer . concat ( state . length ) ;
11961196 state . buffer . clear ( ) ;
11971197 } else {
1198- // read part of list
1198+ // read part of list.
11991199 ret = state . buffer . consume ( n , state . decoder ) ;
12001200 }
12011201
@@ -1224,7 +1224,7 @@ function endReadableNT(state, stream) {
12241224 process . nextTick ( endWritableNT , state , stream ) ;
12251225 } else if ( state . autoDestroy ) {
12261226 // In case of duplex streams we need a way to detect
1227- // if the writable side is ready for autoDestroy as well
1227+ // if the writable side is ready for autoDestroy as well.
12281228 const wState = stream . _writableState ;
12291229 const autoDestroy = ! wState || (
12301230 wState . autoDestroy &&
0 commit comments