stream: change var to let/const in stream files
PR-URL: https://github.com/nodejs/node/pull/32214 Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
This commit is contained in:
parent
2bf02285a3
commit
4fc13b016a
@ -443,7 +443,7 @@ Readable.prototype.read = function(n) {
|
|||||||
// 3. Actually pull the requested chunks out of the buffer and return.
|
// 3. Actually pull the requested chunks out of the buffer and return.
|
||||||
|
|
||||||
// if we need a readable event, then we need to do some reading.
|
// if we need a readable event, then we need to do some reading.
|
||||||
var doRead = state.needReadable;
|
let doRead = state.needReadable;
|
||||||
debug('need readable', doRead);
|
debug('need readable', doRead);
|
||||||
|
|
||||||
// If we currently have less than the highWaterMark, then also read some
|
// If we currently have less than the highWaterMark, then also read some
|
||||||
@ -474,7 +474,7 @@ Readable.prototype.read = function(n) {
|
|||||||
n = howMuchToRead(nOrig, state);
|
n = howMuchToRead(nOrig, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
var ret;
|
let ret;
|
||||||
if (n > 0)
|
if (n > 0)
|
||||||
ret = fromList(n, state);
|
ret = fromList(n, state);
|
||||||
else
|
else
|
||||||
@ -513,7 +513,7 @@ function onEofChunk(stream, state) {
|
|||||||
debug('onEofChunk');
|
debug('onEofChunk');
|
||||||
if (state.ended) return;
|
if (state.ended) return;
|
||||||
if (state.decoder) {
|
if (state.decoder) {
|
||||||
var chunk = state.decoder.end();
|
const chunk = state.decoder.end();
|
||||||
if (chunk && chunk.length) {
|
if (chunk && chunk.length) {
|
||||||
state.buffer.push(chunk);
|
state.buffer.push(chunk);
|
||||||
state.length += state.objectMode ? 1 : chunk.length;
|
state.length += state.objectMode ? 1 : chunk.length;
|
||||||
@ -674,7 +674,7 @@ Readable.prototype.pipe = function(dest, pipeOpts) {
|
|||||||
|
|
||||||
let ondrain;
|
let ondrain;
|
||||||
|
|
||||||
var cleanedUp = false;
|
let cleanedUp = false;
|
||||||
function cleanup() {
|
function cleanup() {
|
||||||
debug('cleanup');
|
debug('cleanup');
|
||||||
// Cleanup event handlers once the pipe is broken
|
// Cleanup event handlers once the pipe is broken
|
||||||
@ -817,7 +817,7 @@ Readable.prototype.unpipe = function(dest) {
|
|||||||
|
|
||||||
if (!dest) {
|
if (!dest) {
|
||||||
// remove all.
|
// remove all.
|
||||||
var dests = state.pipes;
|
const dests = state.pipes;
|
||||||
state.pipes = [];
|
state.pipes = [];
|
||||||
this.pause();
|
this.pause();
|
||||||
|
|
||||||
@ -985,12 +985,12 @@ function flow(stream) {
|
|||||||
// It is an ugly unfortunate mess of history.
|
// It is an ugly unfortunate mess of history.
|
||||||
Readable.prototype.wrap = function(stream) {
|
Readable.prototype.wrap = function(stream) {
|
||||||
const state = this._readableState;
|
const state = this._readableState;
|
||||||
var paused = false;
|
let paused = false;
|
||||||
|
|
||||||
stream.on('end', () => {
|
stream.on('end', () => {
|
||||||
debug('wrapped end');
|
debug('wrapped end');
|
||||||
if (state.decoder && !state.ended) {
|
if (state.decoder && !state.ended) {
|
||||||
var chunk = state.decoder.end();
|
const chunk = state.decoder.end();
|
||||||
if (chunk && chunk.length)
|
if (chunk && chunk.length)
|
||||||
this.push(chunk);
|
this.push(chunk);
|
||||||
}
|
}
|
||||||
@ -1179,7 +1179,7 @@ function fromList(n, state) {
|
|||||||
if (state.length === 0)
|
if (state.length === 0)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var ret;
|
let ret;
|
||||||
if (state.objectMode)
|
if (state.objectMode)
|
||||||
ret = state.buffer.shift();
|
ret = state.buffer.shift();
|
||||||
else if (!n || n >= state.length) {
|
else if (!n || n >= state.length) {
|
||||||
|
@ -172,7 +172,7 @@ Transform.prototype._write = function(chunk, encoding, cb) {
|
|||||||
ts.writechunk = chunk;
|
ts.writechunk = chunk;
|
||||||
ts.writeencoding = encoding;
|
ts.writeencoding = encoding;
|
||||||
if (!ts.transforming) {
|
if (!ts.transforming) {
|
||||||
var rs = this._readableState;
|
const rs = this._readableState;
|
||||||
if (ts.needTransform ||
|
if (ts.needTransform ||
|
||||||
rs.needReadable ||
|
rs.needReadable ||
|
||||||
rs.length < rs.highWaterMark)
|
rs.length < rs.highWaterMark)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user