Skip to content

Commit 802edb1

Browse files
committedApr 24, 2020
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 cd4052c commit 802edb1

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. 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().
220220
Readable.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.
342342
const MAX_HWM = 0x40000000;
343343
function 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.
848848
Readable.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.
10621062
ObjectDefineProperties(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.
11801180
function 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 &&

‎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))
@@ -487,7 +487,7 @@ function errorBuffer(state, err) {
487487
resetBuffer(state);
488488
}
489489

490-
// If there's something in the buffer waiting, then process it
490+
// If there's something in the buffer waiting, then process it.
491491
function clearBuffer(stream, state) {
492492
if (state.corked || state.bufferProcessing) {
493493
return;
@@ -564,7 +564,7 @@ Writable.prototype.end = function(chunk, encoding, cb) {
564564
if (chunk !== null && chunk !== undefined)
565565
this.write(chunk, encoding);
566566

567-
// .end() fully uncorks
567+
// .end() fully uncorks.
568568
if (state.corked) {
569569
state.corked = 1;
570570
this.uncork();
@@ -662,7 +662,7 @@ function finish(stream, state) {
662662

663663
if (state.autoDestroy) {
664664
// In case of duplex streams we need a way to detect
665-
// if the readable side is ready for autoDestroy as well
665+
// if the readable side is ready for autoDestroy as well.
666666
const rState = stream._readableState;
667667
const autoDestroy = !rState || (
668668
rState.autoDestroy &&
@@ -703,7 +703,7 @@ ObjectDefineProperties(Writable.prototype, {
703703
return this._writableState ? this._writableState.destroyed : false;
704704
},
705705
set(value) {
706-
// Backward compatibility, the user is explicitly managing destroyed
706+
// Backward compatibility, the user is explicitly managing destroyed.
707707
if (this._writableState) {
708708
this._writableState.destroyed = value;
709709
}

0 commit comments

Comments
 (0)
Please sign in to comment.