Skip to content

Commit bb5cd7b

Browse files
ronagBethGriggs
authored andcommitted
stream: consistent punctuation
Cleanup comments to use consistent punctuation. PR-URL: #32934 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Gerhard Stöbich <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Juan José Arboleda <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
1 parent 2db3654 commit bb5cd7b

File tree

3 files changed

+48
-48
lines changed

3 files changed

+48
-48
lines changed

lib/_stream_duplex.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ ObjectDefineProperties(Duplex.prototype, {
8383
},
8484
set(value) {
8585
// Backward compatibility, the user is explicitly
86-
// managing destroyed
86+
// managing destroyed.
8787
if (this._readableState && this._writableState) {
8888
this._readableState.destroyed = value;
8989
this._writableState.destroyed = value;

lib/_stream_readable.js

+31-31
Original file line numberDiff line numberDiff line change
@@ -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().
217217
Readable.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.
339339
const MAX_HWM = 0x40000000;
340340
function 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.
845845
Readable.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.
10591059
ObjectDefineProperties(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.
11771177
function 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 &&

lib/_stream_writable.js

+16-16
Original file line numberDiff line numberDiff line change
@@ -83,21 +83,21 @@ function WritableState(options, stream, isDuplex) {
8383

8484
// The point at which write() starts returning false
8585
// Note: 0 is a valid value, means that we always return false if
86-
// the entire buffer is not flushed immediately on write()
86+
// the entire buffer is not flushed immediately on write().
8787
this.highWaterMark = options ?
8888
getHighWaterMark(this, options, 'writableHighWaterMark', isDuplex) :
8989
getDefaultHighWaterMark(false);
9090

91-
// if _final has been called
91+
// if _final has been called.
9292
this.finalCalled = false;
9393

9494
// drain event flag.
9595
this.needDrain = false;
9696
// At the start of calling end()
9797
this.ending = false;
98-
// When end() has been called, and returned
98+
// When end() has been called, and returned.
9999
this.ended = false;
100-
// When 'finish' is emitted
100+
// When 'finish' is emitted.
101101
this.finished = false;
102102

103103
// Has it been destroyed
@@ -122,7 +122,7 @@ function WritableState(options, stream, isDuplex) {
122122
// A flag to see when we're in the middle of a write.
123123
this.writing = false;
124124

125-
// When true all writes will be buffered until .uncork() call
125+
// When true all writes will be buffered until .uncork() call.
126126
this.corked = 0;
127127

128128
// A flag to be able to tell if the onwrite cb is called immediately,
@@ -136,10 +136,10 @@ function WritableState(options, stream, isDuplex) {
136136
// end up in an overlapped onwrite situation.
137137
this.bufferProcessing = false;
138138

139-
// The callback that's passed to _write(chunk,cb)
139+
// The callback that's passed to _write(chunk, cb).
140140
this.onwrite = onwrite.bind(undefined, stream);
141141

142-
// The callback that the user supplies to write(chunk,encoding,cb)
142+
// The callback that the user supplies to write(chunk, encoding, cb).
143143
this.writecb = null;
144144

145145
// The amount that is being written when _write is called.
@@ -152,20 +152,20 @@ function WritableState(options, stream, isDuplex) {
152152
resetBuffer(this);
153153

154154
// Number of pending user-supplied write callbacks
155-
// this must be 0 before 'finish' can be emitted
155+
// this must be 0 before 'finish' can be emitted.
156156
this.pendingcb = 0;
157157

158158
// Emit prefinish if the only thing we're waiting for is _write cbs
159-
// This is relevant for synchronous Transform streams
159+
// This is relevant for synchronous Transform streams.
160160
this.prefinished = false;
161161

162-
// True if the error was already emitted and should not be thrown again
162+
// True if the error was already emitted and should not be thrown again.
163163
this.errorEmitted = false;
164164

165165
// Should close be emitted on destroy. Defaults to true.
166166
this.emitClose = !options || options.emitClose !== false;
167167

168-
// Should .destroy() be called after 'finish' (and potentially 'end')
168+
// Should .destroy() be called after 'finish' (and potentially 'end').
169169
this.autoDestroy = !options || options.autoDestroy !== false;
170170

171171
// Indicates whether the stream has errored. When true all write() calls
@@ -225,7 +225,7 @@ function Writable(options) {
225225
// `_writableState` that would lead to infinite recursion.
226226

227227
// Checking for a Stream.Duplex instance is faster here instead of inside
228-
// the WritableState constructor, at least with V8 6.5
228+
// the WritableState constructor, at least with V8 6.5.
229229
const isDuplex = (this instanceof Stream.Duplex);
230230

231231
if (!isDuplex && !realHasInstance.call(Writable, this))
@@ -480,7 +480,7 @@ function errorBuffer(state, err) {
480480
resetBuffer(state);
481481
}
482482

483-
// If there's something in the buffer waiting, then process it
483+
// If there's something in the buffer waiting, then process it.
484484
function clearBuffer(stream, state) {
485485
if (state.corked || state.bufferProcessing) {
486486
return;
@@ -557,7 +557,7 @@ Writable.prototype.end = function(chunk, encoding, cb) {
557557
if (chunk !== null && chunk !== undefined)
558558
this.write(chunk, encoding);
559559

560-
// .end() fully uncorks
560+
// .end() fully uncorks.
561561
if (state.corked) {
562562
state.corked = 1;
563563
this.uncork();
@@ -649,7 +649,7 @@ function finish(stream, state) {
649649

650650
if (state.autoDestroy) {
651651
// In case of duplex streams we need a way to detect
652-
// if the readable side is ready for autoDestroy as well
652+
// if the readable side is ready for autoDestroy as well.
653653
const rState = stream._readableState;
654654
const autoDestroy = !rState || (
655655
rState.autoDestroy &&
@@ -690,7 +690,7 @@ ObjectDefineProperties(Writable.prototype, {
690690
return this._writableState ? this._writableState.destroyed : false;
691691
},
692692
set(value) {
693-
// Backward compatibility, the user is explicitly managing destroyed
693+
// Backward compatibility, the user is explicitly managing destroyed.
694694
if (this._writableState) {
695695
this._writableState.destroyed = value;
696696
}

0 commit comments

Comments
 (0)