@@ -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.
@@ -156,11 +156,11 @@ function ReadableState(options, stream, isDuplex) {
156156 this . defaultEncoding = ( options && options . defaultEncoding ) || 'utf8' ;
157157
158158 // Ref the piped dest which we need a drain event on it
159- // type: null | Writable | Set<Writable>
159+ // type: null | Writable | Set<Writable>.
160160 this . awaitDrainWriters = null ;
161161 this . multiAwaitDrain = false ;
162162
163- // If true, a maybeReadMore has been scheduled
163+ // If true, a maybeReadMore has been scheduled.
164164 this . readingMore = false ;
165165
166166 this . decoder = null ;
@@ -179,7 +179,7 @@ function Readable(options) {
179179 return new Readable ( options ) ;
180180
181181 // Checking for a Stream.Duplex instance is faster here instead of inside
182- // the ReadableState constructor, at least with V8 6.5
182+ // the ReadableState constructor, at least with V8 6.5.
183183 const isDuplex = this instanceof Stream . Duplex ;
184184
185185 this . _readableState = new ReadableState ( options , this , isDuplex ) ;
@@ -213,7 +213,7 @@ Readable.prototype.push = function(chunk, encoding) {
213213 return readableAddChunk ( this , chunk , encoding , false ) ;
214214} ;
215215
216- // Unshift should *always* be something directly out of read()
216+ // Unshift should *always* be something directly out of read().
217217Readable . prototype . unshift = function ( chunk , encoding ) {
218218 return readableAddChunk ( this , chunk , encoding , true ) ;
219219} ;
@@ -228,7 +228,7 @@ function readableAddChunk(stream, chunk, encoding, addToFront) {
228228 encoding = encoding || state . defaultEncoding ;
229229 if ( addToFront && state . encoding && state . encoding !== encoding ) {
230230 // When unshifting, if state.encoding is set, we have to save
231- // the string in the BufferList with the state encoding
231+ // the string in the BufferList with the state encoding.
232232 chunk = Buffer . from ( chunk , encoding ) . toString ( state . encoding ) ;
233233 } else if ( encoding !== state . encoding ) {
234234 chunk = Buffer . from ( chunk , encoding ) ;
@@ -319,7 +319,7 @@ Readable.prototype.setEncoding = function(enc) {
319319 StringDecoder = require ( 'string_decoder' ) . StringDecoder ;
320320 const decoder = new StringDecoder ( enc ) ;
321321 this . _readableState . decoder = decoder ;
322- // If setEncoding(null), decoder.encoding equals utf8
322+ // If setEncoding(null), decoder.encoding equals utf8.
323323 this . _readableState . encoding = this . _readableState . decoder . encoding ;
324324
325325 const buffer = this . _readableState . buffer ;
@@ -335,15 +335,15 @@ Readable.prototype.setEncoding = function(enc) {
335335 return this ;
336336} ;
337337
338- // Don't raise the hwm > 1GB
338+ // Don't raise the hwm > 1GB.
339339const MAX_HWM = 0x40000000 ;
340340function computeNewHighWaterMark ( n ) {
341341 if ( n >= MAX_HWM ) {
342342 // TODO(ronag): Throw ERR_VALUE_OUT_OF_RANGE.
343343 n = MAX_HWM ;
344344 } else {
345345 // Get the next highest power of 2 to prevent increasing hwm excessively in
346- // tiny amounts
346+ // tiny amounts.
347347 n -- ;
348348 n |= n >>> 1 ;
349349 n |= n >>> 2 ;
@@ -363,7 +363,7 @@ function howMuchToRead(n, state) {
363363 if ( state . objectMode )
364364 return 1 ;
365365 if ( NumberIsNaN ( n ) ) {
366- // Only flow one buffer at a time
366+ // Only flow one buffer at a time.
367367 if ( state . flowing && state . length )
368368 return state . buffer . first ( ) . length ;
369369 else
@@ -446,7 +446,7 @@ Readable.prototype.read = function(n) {
446446 let doRead = state . needReadable ;
447447 debug ( 'need readable' , doRead ) ;
448448
449- // If we currently have less than the highWaterMark, then also read some
449+ // If we currently have less than the highWaterMark, then also read some.
450450 if ( state . length === 0 || state . length - n < state . highWaterMark ) {
451451 doRead = true ;
452452 debug ( 'length less than watermark' , doRead ) ;
@@ -524,7 +524,7 @@ function onEofChunk(stream, state) {
524524 if ( state . sync ) {
525525 // If we are sync, wait until next tick to emit the data.
526526 // Otherwise we risk emitting data in the flow()
527- // the readable code triggers during a read() call
527+ // the readable code triggers during a read() call.
528528 emitReadable ( stream ) ;
529529 } else {
530530 // Emit 'readable' now to make sure it gets picked up.
@@ -558,7 +558,7 @@ function emitReadable_(stream) {
558558 state . emittedReadable = false ;
559559 }
560560
561- // The stream needs another readable event if
561+ // The stream needs another readable event if:
562562 // 1. It is not flowing, as the flow mechanism will take
563563 // care of it.
564564 // 2. It is not ended.
@@ -677,7 +677,7 @@ Readable.prototype.pipe = function(dest, pipeOpts) {
677677 let cleanedUp = false ;
678678 function cleanup ( ) {
679679 debug ( 'cleanup' ) ;
680- // Cleanup event handlers once the pipe is broken
680+ // Cleanup event handlers once the pipe is broken.
681681 dest . removeListener ( 'close' , onclose ) ;
682682 dest . removeListener ( 'finish' , onfinish ) ;
683683 if ( ondrain ) {
@@ -771,7 +771,7 @@ Readable.prototype.pipe = function(dest, pipeOpts) {
771771 src . unpipe ( dest ) ;
772772 }
773773
774- // Tell the dest that it's being piped to
774+ // Tell the dest that it's being piped to.
775775 dest . emit ( 'pipe' , src ) ;
776776
777777 // Start the flow if it hasn't been started already.
@@ -841,7 +841,7 @@ Readable.prototype.unpipe = function(dest) {
841841} ;
842842
843843// Set up data events if they are asked for
844- // Ensure readable listeners eventually get something
844+ // Ensure readable listeners eventually get something.
845845Readable . prototype . on = function ( ev , fn ) {
846846 const res = Stream . prototype . on . call ( this , ev , fn ) ;
847847 const state = this . _readableState ;
@@ -851,7 +851,7 @@ Readable.prototype.on = function(ev, fn) {
851851 // a few lines down. This is needed to support once('readable').
852852 state . readableListening = this . listenerCount ( 'readable' ) > 0 ;
853853
854- // Try start flowing on next tick if stream isn't explicitly paused
854+ // Try start flowing on next tick if stream isn't explicitly paused.
855855 if ( state . flowing !== false )
856856 this . resume ( ) ;
857857 } else if ( ev === 'readable' ) {
@@ -914,7 +914,7 @@ function updateReadableListening(self) {
914914 // the upcoming resume will not flow.
915915 state . flowing = true ;
916916
917- // Crude way to check if we should resume
917+ // Crude way to check if we should resume.
918918 } else if ( self . listenerCount ( 'data' ) > 0 ) {
919919 self . resume ( ) ;
920920 } else if ( ! state . readableListening ) {
@@ -935,7 +935,7 @@ Readable.prototype.resume = function() {
935935 debug ( 'resume' ) ;
936936 // We flow only if there is no one listening
937937 // for readable, but we still have to call
938- // resume()
938+ // resume().
939939 state . flowing = ! state . readableListening ;
940940 resume ( this , state ) ;
941941 }
@@ -1003,7 +1003,7 @@ Readable.prototype.wrap = function(stream) {
10031003 if ( state . decoder )
10041004 chunk = state . decoder . write ( chunk ) ;
10051005
1006- // Don't skip over falsy values in objectMode
1006+ // Don't skip over falsy values in objectMode.
10071007 if ( state . objectMode && ( chunk === null || chunk === undefined ) )
10081008 return ;
10091009 else if ( ! state . objectMode && ( ! chunk || ! chunk . length ) )
@@ -1055,7 +1055,7 @@ Readable.prototype[SymbolAsyncIterator] = function() {
10551055
10561056// Making it explicit these properties are not enumerable
10571057// because otherwise some prototype manipulation in
1058- // userland will fail
1058+ // userland will fail.
10591059ObjectDefineProperties ( Readable . prototype , {
10601060 readable : {
10611061 get ( ) {
@@ -1132,13 +1132,13 @@ ObjectDefineProperties(Readable.prototype, {
11321132 } ,
11331133 set ( value ) {
11341134 // We ignore the value if the stream
1135- // has not been initialized yet
1135+ // has not been initialized yet.
11361136 if ( ! this . _readableState ) {
11371137 return ;
11381138 }
11391139
11401140 // Backward compatibility, the user is explicitly
1141- // managing destroyed
1141+ // managing destroyed.
11421142 this . _readableState . destroyed = value ;
11431143 }
11441144 } ,
@@ -1175,15 +1175,15 @@ Readable._fromList = fromList;
11751175// This function is designed to be inlinable, so please take care when making
11761176// changes to the function body.
11771177function fromList ( n , state ) {
1178- // nothing buffered
1178+ // nothing buffered.
11791179 if ( state . length === 0 )
11801180 return null ;
11811181
11821182 let ret ;
11831183 if ( state . objectMode )
11841184 ret = state . buffer . shift ( ) ;
11851185 else if ( ! n || n >= state . length ) {
1186- // Read it all, truncate the list
1186+ // Read it all, truncate the list.
11871187 if ( state . decoder )
11881188 ret = state . buffer . join ( '' ) ;
11891189 else if ( state . buffer . length === 1 )
@@ -1192,7 +1192,7 @@ function fromList(n, state) {
11921192 ret = state . buffer . concat ( state . length ) ;
11931193 state . buffer . clear ( ) ;
11941194 } else {
1195- // read part of list
1195+ // read part of list.
11961196 ret = state . buffer . consume ( n , state . decoder ) ;
11971197 }
11981198
@@ -1221,7 +1221,7 @@ function endReadableNT(state, stream) {
12211221 process . nextTick ( endWritableNT , state , stream ) ;
12221222 } else if ( state . autoDestroy ) {
12231223 // In case of duplex streams we need a way to detect
1224- // if the writable side is ready for autoDestroy as well
1224+ // if the writable side is ready for autoDestroy as well.
12251225 const wState = stream . _writableState ;
12261226 const autoDestroy = ! wState || (
12271227 wState . autoDestroy &&
0 commit comments