Skip to content

Commit c8b6de2

Browse files
Trottrvagg
authored andcommitted
stream: refactor redeclared variables
`lib/_stream_readable.js` contained three instances of `var` declarations occurring twice in the same scope. Refactored to `const` or `let` as appropriate. PR-URL: #4816 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent ae9a8cd commit c8b6de2

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

‎lib/_stream_readable.js‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,10 @@ function readableAddChunk(stream, state, chunk, encoding, addToFront){
130130
onEofChunk(stream,state);
131131
}elseif(state.objectMode||chunk&&chunk.length>0){
132132
if(state.ended&&!addToFront){
133-
vare=newError('stream.push() after EOF');
133+
conste=newError('stream.push() after EOF');
134134
stream.emit('error',e);
135135
}elseif(state.endEmitted&&addToFront){
136-
vare=newError('stream.unshift() after end event');
136+
conste=newError('stream.unshift() after end event');
137137
stream.emit('error',e);
138138
}else{
139139
if(state.decoder&&!addToFront&&!encoding)
@@ -640,13 +640,13 @@ Readable.prototype.unpipe = function(dest){
640640
state.pipesCount=0;
641641
state.flowing=false;
642642

643-
for(vari=0;i<len;i++)
643+
for(leti=0;i<len;i++)
644644
dests[i].emit('unpipe',this);
645645
returnthis;
646646
}
647647

648648
// try to find the right one.
649-
vari=state.pipes.indexOf(dest);
649+
consti=state.pipes.indexOf(dest);
650650
if(i===-1)
651651
returnthis;
652652

@@ -847,7 +847,7 @@ function fromList(n, state){
847847
if(n<list[0].length){
848848
// just take a part of the first list item.
849849
// slice is the same for buffers and strings.
850-
varbuf=list[0];
850+
constbuf=list[0];
851851
ret=buf.slice(0,n);
852852
list[0]=buf.slice(n);
853853
}elseif(n===list[0].length){
@@ -863,7 +863,7 @@ function fromList(n, state){
863863

864864
varc=0;
865865
for(vari=0,l=list.length;i<l&&c<n;i++){
866-
varbuf=list[0];
866+
constbuf=list[0];
867867
varcpy=Math.min(n-c,buf.length);
868868

869869
if(stringMode)

0 commit comments

Comments
(0)