| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 988c2fe commit 4c10b5f
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -83,7 +83,7 @@ ObjectDefineProperties(Duplex.prototype, { | |||
| 83 | 83 | }, | |
| 84 | 84 | set(value) { | |
| 85 | 85 | // Backward compatibility, the user is explicitly | |
| 86 | - // managing destroyed | ||
| 86 | + // managing destroyed. | ||
| 87 | 87 | if (this._readableState && this._writableState) { | |
| 88 | 88 | this._readableState.destroyed = value; | |
| 89 | 89 | this._writableState.destroyed = value; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -94,7 +94,7 @@ function ReadableState(options, stream, isDuplex) { | |||
| 94 | 94 | isDuplex = stream instanceof Stream.Duplex; | |
| 95 | 95 | ||
| 96 | 96 | // 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. | ||
| 98 | 98 | this.objectMode = !!(options && options.objectMode); | |
| 99 | 99 | ||
| 100 | 100 | if (isDuplex) | |
@@ -109,7 +109,7 @@ function ReadableState(options, stream, isDuplex) { | |||
| 109 | 109 | ||
| 110 | 110 | // A linked list is used to store data chunks instead of an array because the | |
| 111 | 111 | // linked list can remove elements from the beginning faster than | |
| 112 | - // array.shift() | ||
| 112 | + // array.shift(). | ||
| 113 | 113 | this.buffer = new BufferList(); | |
| 114 | 114 | this.length = 0; | |
| 115 | 115 | this.pipes = []; | |
@@ -132,16 +132,16 @@ function ReadableState(options, stream, isDuplex) { | |||
| 132 | 132 | this.resumeScheduled = false; | |
| 133 | 133 | this[kPaused] = null; | |
| 134 | 134 | ||
| 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. | ||
| 136 | 136 | this.errorEmitted = false; | |
| 137 | 137 | ||
| 138 | 138 | // Should close be emitted on destroy. Defaults to true. | |
| 139 | 139 | this.emitClose = !options || options.emitClose !== false; | |
| 140 | 140 | ||
| 141 | - // Should .destroy() be called after 'end' (and potentially 'finish') | ||
| 141 | + // Should .destroy() be called after 'end' (and potentially 'finish'). | ||
| 142 | 142 | this.autoDestroy = !options || options.autoDestroy !== false; | |
| 143 | 143 | ||
| 144 | - // Has it been destroyed | ||
| 144 | + // Has it been destroyed. | ||
| 145 | 145 | this.destroyed = false; | |
| 146 | 146 | ||
| 147 | 147 | // Indicates whether the stream has errored. | |
@@ -156,11 +156,11 @@ function ReadableState(options, stream, isDuplex) { | |||
| 156 | 156 | this.defaultEncoding = (options && options.defaultEncoding) || 'utf8'; | |
| 157 | 157 | ||
| 158 | 158 | // Ref the piped dest which we need a drain event on it | |
| 159 | - // type: null | Writable | Set<Writable> | ||
| 159 | + // type: null | Writable | Set<Writable>. | ||
| 160 | 160 | this.awaitDrainWriters = null; | |
| 161 | 161 | this.multiAwaitDrain = false; | |
| 162 | 162 | ||
| 163 | - // If true, a maybeReadMore has been scheduled | ||
| 163 | + // If true, a maybeReadMore has been scheduled. | ||
| 164 | 164 | this.readingMore = false; | |
| 165 | 165 | ||
| 166 | 166 | this.decoder = null; | |
@@ -179,7 +179,7 @@ function Readable(options) { | |||
| 179 | 179 | return new Readable(options); | |
| 180 | 180 | ||
| 181 | 181 | // 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. | ||
| 183 | 183 | const isDuplex = this instanceof Stream.Duplex; | |
| 184 | 184 | ||
| 185 | 185 | this._readableState = new ReadableState(options, this, isDuplex); | |
@@ -213,7 +213,7 @@ Readable.prototype.push = function(chunk, encoding) { | |||
| 213 | 213 | return readableAddChunk(this, chunk, encoding, false); | |
| 214 | 214 | }; | |
| 215 | 215 | ||
| 216 | - // Unshift should *always* be something directly out of read() | ||
| 216 | + // Unshift should *always* be something directly out of read(). | ||
| 217 | 217 | Readable.prototype.unshift = function(chunk, encoding) { | |
| 218 | 218 | return readableAddChunk(this, chunk, encoding, true); | |
| 219 | 219 | }; | |
@@ -228,7 +228,7 @@ function readableAddChunk(stream, chunk, encoding, addToFront) { | |||
| 228 | 228 | encoding = encoding || state.defaultEncoding; | |
| 229 | 229 | if (addToFront && state.encoding && state.encoding !== encoding) { | |
| 230 | 230 | // 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. | ||
| 232 | 232 | chunk = Buffer.from(chunk, encoding).toString(state.encoding); | |
| 233 | 233 | } else if (encoding !== state.encoding) { | |
| 234 | 234 | chunk = Buffer.from(chunk, encoding); | |
@@ -319,7 +319,7 @@ Readable.prototype.setEncoding = function(enc) { | |||
| 319 | 319 | StringDecoder = require('string_decoder').StringDecoder; | |
| 320 | 320 | const decoder = new StringDecoder(enc); | |
| 321 | 321 | this._readableState.decoder = decoder; | |
| 322 | - // If setEncoding(null), decoder.encoding equals utf8 | ||
| 322 | + // If setEncoding(null), decoder.encoding equals utf8. | ||
| 323 | 323 | this._readableState.encoding = this._readableState.decoder.encoding; | |
| 324 | 324 | ||
| 325 | 325 | const buffer = this._readableState.buffer; | |
@@ -335,15 +335,15 @@ Readable.prototype.setEncoding = function(enc) { | |||
| 335 | 335 | return this; | |
| 336 | 336 | }; | |
| 337 | 337 | ||
| 338 | - // Don't raise the hwm > 1GB | ||
| 338 | + // Don't raise the hwm > 1GB. | ||
| 339 | 339 | const MAX_HWM = 0x40000000; | |
| 340 | 340 | function computeNewHighWaterMark(n) { | |
| 341 | 341 | if (n >= MAX_HWM) { | |
| 342 | 342 | // TODO(ronag): Throw ERR_VALUE_OUT_OF_RANGE. | |
| 343 | 343 | n = MAX_HWM; | |
| 344 | 344 | } else { | |
| 345 | 345 | // Get the next highest power of 2 to prevent increasing hwm excessively in | |
| 346 | - // tiny amounts | ||
| 346 | + // tiny amounts. | ||
| 347 | 347 | n--; | |
| 348 | 348 | n |= n >>> 1; | |
| 349 | 349 | n |= n >>> 2; | |
@@ -363,7 +363,7 @@ function howMuchToRead(n, state) { | |||
| 363 | 363 | if (state.objectMode) | |
| 364 | 364 | return 1; | |
| 365 | 365 | if (NumberIsNaN(n)) { | |
| 366 | - // Only flow one buffer at a time | ||
| 366 | + // Only flow one buffer at a time. | ||
| 367 | 367 | if (state.flowing && state.length) | |
| 368 | 368 | return state.buffer.first().length; | |
| 369 | 369 | else | |
@@ -446,7 +446,7 @@ Readable.prototype.read = function(n) { | |||
| 446 | 446 | let doRead = state.needReadable; | |
| 447 | 447 | debug('need readable', doRead); | |
| 448 | 448 | ||
| 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. | ||
| 450 | 450 | if (state.length === 0 || state.length - n < state.highWaterMark) { | |
| 451 | 451 | doRead = true; | |
| 452 | 452 | debug('length less than watermark', doRead); | |
@@ -524,7 +524,7 @@ function onEofChunk(stream, state) { | |||
| 524 | 524 | if (state.sync) { | |
| 525 | 525 | // If we are sync, wait until next tick to emit the data. | |
| 526 | 526 | // 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. | ||
| 528 | 528 | emitReadable(stream); | |
| 529 | 529 | } else { | |
| 530 | 530 | // Emit 'readable' now to make sure it gets picked up. | |
@@ -558,7 +558,7 @@ function emitReadable_(stream) { | |||
| 558 | 558 | state.emittedReadable = false; | |
| 559 | 559 | } | |
| 560 | 560 | ||
| 561 | - // The stream needs another readable event if | ||
| 561 | + // The stream needs another readable event if: | ||
| 562 | 562 | // 1. It is not flowing, as the flow mechanism will take | |
| 563 | 563 | // care of it. | |
| 564 | 564 | // 2. It is not ended. | |
@@ -677,7 +677,7 @@ Readable.prototype.pipe = function(dest, pipeOpts) { | |||
| 677 | 677 | let cleanedUp = false; | |
| 678 | 678 | function cleanup() { | |
| 679 | 679 | debug('cleanup'); | |
| 680 | - // Cleanup event handlers once the pipe is broken | ||
| 680 | + // Cleanup event handlers once the pipe is broken. | ||
| 681 | 681 | dest.removeListener('close', onclose); | |
| 682 | 682 | dest.removeListener('finish', onfinish); | |
| 683 | 683 | if (ondrain) { | |
@@ -771,7 +771,7 @@ Readable.prototype.pipe = function(dest, pipeOpts) { | |||
| 771 | 771 | src.unpipe(dest); | |
| 772 | 772 | } | |
| 773 | 773 | ||
| 774 | - // Tell the dest that it's being piped to | ||
| 774 | + // Tell the dest that it's being piped to. | ||
| 775 | 775 | dest.emit('pipe', src); | |
| 776 | 776 | ||
| 777 | 777 | // Start the flow if it hasn't been started already. | |
@@ -841,7 +841,7 @@ Readable.prototype.unpipe = function(dest) { | |||
| 841 | 841 | }; | |
| 842 | 842 | ||
| 843 | 843 | // Set up data events if they are asked for | |
| 844 | - // Ensure readable listeners eventually get something | ||
| 844 | + // Ensure readable listeners eventually get something. | ||
| 845 | 845 | Readable.prototype.on = function(ev, fn) { | |
| 846 | 846 | const res = Stream.prototype.on.call(this, ev, fn); | |
| 847 | 847 | const state = this._readableState; | |
@@ -851,7 +851,7 @@ Readable.prototype.on = function(ev, fn) { | |||
| 851 | 851 | // a few lines down. This is needed to support once('readable'). | |
| 852 | 852 | state.readableListening = this.listenerCount('readable') > 0; | |
| 853 | 853 | ||
| 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. | ||
| 855 | 855 | if (state.flowing !== false) | |
| 856 | 856 | this.resume(); | |
| 857 | 857 | } else if (ev === 'readable') { | |
@@ -914,7 +914,7 @@ function updateReadableListening(self) { | |||
| 914 | 914 | // the upcoming resume will not flow. | |
| 915 | 915 | state.flowing = true; | |
| 916 | 916 | ||
| 917 | - // Crude way to check if we should resume | ||
| 917 | + // Crude way to check if we should resume. | ||
| 918 | 918 | } else if (self.listenerCount('data') > 0) { | |
| 919 | 919 | self.resume(); | |
| 920 | 920 | } else if (!state.readableListening) { | |
@@ -935,7 +935,7 @@ Readable.prototype.resume = function() { | |||
| 935 | 935 | debug('resume'); | |
| 936 | 936 | // We flow only if there is no one listening | |
| 937 | 937 | // for readable, but we still have to call | |
| 938 | - // resume() | ||
| 938 | + // resume(). | ||
| 939 | 939 | state.flowing = !state.readableListening; | |
| 940 | 940 | resume(this, state); | |
| 941 | 941 | } | |
@@ -1003,7 +1003,7 @@ Readable.prototype.wrap = function(stream) { | |||
| 1003 | 1003 | if (state.decoder) | |
| 1004 | 1004 | chunk = state.decoder.write(chunk); | |
| 1005 | 1005 | ||
| 1006 | - // Don't skip over falsy values in objectMode | ||
| 1006 | + // Don't skip over falsy values in objectMode. | ||
| 1007 | 1007 | if (state.objectMode && (chunk === null || chunk === undefined)) | |
| 1008 | 1008 | return; | |
| 1009 | 1009 | else if (!state.objectMode && (!chunk || !chunk.length)) | |
@@ -1055,7 +1055,7 @@ Readable.prototype[SymbolAsyncIterator] = function() { | |||
| 1055 | 1055 | ||
| 1056 | 1056 | // Making it explicit these properties are not enumerable | |
| 1057 | 1057 | // because otherwise some prototype manipulation in | |
| 1058 | - // userland will fail | ||
| 1058 | + // userland will fail. | ||
| 1059 | 1059 | ObjectDefineProperties(Readable.prototype, { | |
| 1060 | 1060 | readable: { | |
| 1061 | 1061 | get() { | |
@@ -1132,13 +1132,13 @@ ObjectDefineProperties(Readable.prototype, { | |||
| 1132 | 1132 | }, | |
| 1133 | 1133 | set(value) { | |
| 1134 | 1134 | // We ignore the value if the stream | |
| 1135 | - // has not been initialized yet | ||
| 1135 | + // has not been initialized yet. | ||
| 1136 | 1136 | if (!this._readableState) { | |
| 1137 | 1137 | return; | |
| 1138 | 1138 | } | |
| 1139 | 1139 | ||
| 1140 | 1140 | // Backward compatibility, the user is explicitly | |
| 1141 | - // managing destroyed | ||
| 1141 | + // managing destroyed. | ||
| 1142 | 1142 | this._readableState.destroyed = value; | |
| 1143 | 1143 | } | |
| 1144 | 1144 | }, | |
@@ -1175,15 +1175,15 @@ Readable._fromList = fromList; | |||
| 1175 | 1175 | // This function is designed to be inlinable, so please take care when making | |
| 1176 | 1176 | // changes to the function body. | |
| 1177 | 1177 | function fromList(n, state) { | |
| 1178 | - // nothing buffered | ||
| 1178 | + // nothing buffered. | ||
| 1179 | 1179 | if (state.length === 0) | |
| 1180 | 1180 | return null; | |
| 1181 | 1181 | ||
| 1182 | 1182 | let ret; | |
| 1183 | 1183 | if (state.objectMode) | |
| 1184 | 1184 | ret = state.buffer.shift(); | |
| 1185 | 1185 | else if (!n || n >= state.length) { | |
| 1186 | - // Read it all, truncate the list | ||
| 1186 | + // Read it all, truncate the list. | ||
| 1187 | 1187 | if (state.decoder) | |
| 1188 | 1188 | ret = state.buffer.join(''); | |
| 1189 | 1189 | else if (state.buffer.length === 1) | |
@@ -1192,7 +1192,7 @@ function fromList(n, state) { | |||
| 1192 | 1192 | ret = state.buffer.concat(state.length); | |
| 1193 | 1193 | state.buffer.clear(); | |
| 1194 | 1194 | } else { | |
| 1195 | - // read part of list | ||
| 1195 | + // read part of list. | ||
| 1196 | 1196 | ret = state.buffer.consume(n, state.decoder); | |
| 1197 | 1197 | } | |
| 1198 | 1198 | ||
@@ -1221,7 +1221,7 @@ function endReadableNT(state, stream) { | |||
| 1221 | 1221 | process.nextTick(endWritableNT, state, stream); | |
| 1222 | 1222 | } else if (state.autoDestroy) { | |
| 1223 | 1223 | // 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. | ||
| 1225 | 1225 | const wState = stream._writableState; | |
| 1226 | 1226 | const autoDestroy = !wState || ( | |
| 1227 | 1227 | wState.autoDestroy && | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -83,21 +83,21 @@ function WritableState(options, stream, isDuplex) { | |||
| 83 | 83 | ||
| 84 | 84 | // The point at which write() starts returning false | |
| 85 | 85 | // 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(). | ||
| 87 | 87 | this.highWaterMark = options ? | |
| 88 | 88 | getHighWaterMark(this, options, 'writableHighWaterMark', isDuplex) : | |
| 89 | 89 | getDefaultHighWaterMark(false); | |
| 90 | 90 | ||
| 91 | - // if _final has been called | ||
| 91 | + // if _final has been called. | ||
| 92 | 92 | this.finalCalled = false; | |
| 93 | 93 | ||
| 94 | 94 | // drain event flag. | |
| 95 | 95 | this.needDrain = false; | |
| 96 | 96 | // At the start of calling end() | |
| 97 | 97 | this.ending = false; | |
| 98 | - // When end() has been called, and returned | ||
| 98 | + // When end() has been called, and returned. | ||
| 99 | 99 | this.ended = false; | |
| 100 | - // When 'finish' is emitted | ||
| 100 | + // When 'finish' is emitted. | ||
| 101 | 101 | this.finished = false; | |
| 102 | 102 | ||
| 103 | 103 | // Has it been destroyed | |
@@ -122,7 +122,7 @@ function WritableState(options, stream, isDuplex) { | |||
| 122 | 122 | // A flag to see when we're in the middle of a write. | |
| 123 | 123 | this.writing = false; | |
| 124 | 124 | ||
| 125 | - // When true all writes will be buffered until .uncork() call | ||
| 125 | + // When true all writes will be buffered until .uncork() call. | ||
| 126 | 126 | this.corked = 0; | |
| 127 | 127 | ||
| 128 | 128 | // A flag to be able to tell if the onwrite cb is called immediately, | |
@@ -136,10 +136,10 @@ function WritableState(options, stream, isDuplex) { | |||
| 136 | 136 | // end up in an overlapped onwrite situation. | |
| 137 | 137 | this.bufferProcessing = false; | |
| 138 | 138 | ||
| 139 | - // The callback that's passed to _write(chunk,cb) | ||
| 139 | + // The callback that's passed to _write(chunk, cb). | ||
| 140 | 140 | this.onwrite = onwrite.bind(undefined, stream); | |
| 141 | 141 | ||
| 142 | - // The callback that the user supplies to write(chunk,encoding,cb) | ||
| 142 | + // The callback that the user supplies to write(chunk, encoding, cb). | ||
| 143 | 143 | this.writecb = null; | |
| 144 | 144 | ||
| 145 | 145 | // The amount that is being written when _write is called. | |
@@ -152,20 +152,20 @@ function WritableState(options, stream, isDuplex) { | |||
| 152 | 152 | resetBuffer(this); | |
| 153 | 153 | ||
| 154 | 154 | // 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. | ||
| 156 | 156 | this.pendingcb = 0; | |
| 157 | 157 | ||
| 158 | 158 | // 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. | ||
| 160 | 160 | this.prefinished = false; | |
| 161 | 161 | ||
| 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. | ||
| 163 | 163 | this.errorEmitted = false; | |
| 164 | 164 | ||
| 165 | 165 | // Should close be emitted on destroy. Defaults to true. | |
| 166 | 166 | this.emitClose = !options || options.emitClose !== false; | |
| 167 | 167 | ||
| 168 | - // Should .destroy() be called after 'finish' (and potentially 'end') | ||
| 168 | + // Should .destroy() be called after 'finish' (and potentially 'end'). | ||
| 169 | 169 | this.autoDestroy = !options || options.autoDestroy !== false; | |
| 170 | 170 | ||
| 171 | 171 | // Indicates whether the stream has errored. When true all write() calls | |
@@ -225,7 +225,7 @@ function Writable(options) { | |||
| 225 | 225 | // `_writableState` that would lead to infinite recursion. | |
| 226 | 226 | ||
| 227 | 227 | // 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. | ||
| 229 | 229 | const isDuplex = (this instanceof Stream.Duplex); | |
| 230 | 230 | ||
| 231 | 231 | if (!isDuplex && !realHasInstance.call(Writable, this)) | |
@@ -480,7 +480,7 @@ function errorBuffer(state, err) { | |||
| 480 | 480 | resetBuffer(state); | |
| 481 | 481 | } | |
| 482 | 482 | ||
| 483 | - // If there's something in the buffer waiting, then process it | ||
| 483 | + // If there's something in the buffer waiting, then process it. | ||
| 484 | 484 | function clearBuffer(stream, state) { | |
| 485 | 485 | if (state.corked || state.bufferProcessing) { | |
| 486 | 486 | return; | |
@@ -557,7 +557,7 @@ Writable.prototype.end = function(chunk, encoding, cb) { | |||
| 557 | 557 | if (chunk !== null && chunk !== undefined) | |
| 558 | 558 | this.write(chunk, encoding); | |
| 559 | 559 | ||
| 560 | - // .end() fully uncorks | ||
| 560 | + // .end() fully uncorks. | ||
| 561 | 561 | if (state.corked) { | |
| 562 | 562 | state.corked = 1; | |
| 563 | 563 | this.uncork(); | |
@@ -649,7 +649,7 @@ function finish(stream, state) { | |||
| 649 | 649 | ||
| 650 | 650 | if (state.autoDestroy) { | |
| 651 | 651 | // 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. | ||
| 653 | 653 | const rState = stream._readableState; | |
| 654 | 654 | const autoDestroy = !rState || ( | |
| 655 | 655 | rState.autoDestroy && | |
@@ -690,7 +690,7 @@ ObjectDefineProperties(Writable.prototype, { | |||
| 690 | 690 | return this._writableState ? this._writableState.destroyed : false; | |
| 691 | 691 | }, | |
| 692 | 692 | set(value) { | |
| 693 | - // Backward compatibility, the user is explicitly managing destroyed | ||
| 693 | + // Backward compatibility, the user is explicitly managing destroyed. | ||
| 694 | 694 | if (this._writableState) { | |
| 695 | 695 | this._writableState.destroyed = value; | |
| 696 | 696 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments