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

+6-6
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,10 @@ function readableAddChunk(stream, state, chunk, encoding, addToFront) {
130130
onEofChunk(stream, state);
131131
} else if (state.objectMode || chunk && chunk.length > 0) {
132132
if (state.ended && !addToFront) {
133-
var e = new Error('stream.push() after EOF');
133+
const e = new Error('stream.push() after EOF');
134134
stream.emit('error', e);
135135
} else if (state.endEmitted && addToFront) {
136-
var e = new Error('stream.unshift() after end event');
136+
const e = new Error('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 (var i = 0; i < len; i++)
643+
for (let i = 0; i < len; i++)
644644
dests[i].emit('unpipe', this);
645645
return this;
646646
}
647647

648648
// try to find the right one.
649-
var i = state.pipes.indexOf(dest);
649+
const i = state.pipes.indexOf(dest);
650650
if (i === -1)
651651
return this;
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-
var buf = list[0];
850+
const buf = list[0];
851851
ret = buf.slice(0, n);
852852
list[0] = buf.slice(n);
853853
} else if (n === list[0].length) {
@@ -863,7 +863,7 @@ function fromList(n, state) {
863863

864864
var c = 0;
865865
for (var i = 0, l = list.length; i < l && c < n; i++) {
866-
var buf = list[0];
866+
const buf = list[0];
867867
var cpy = Math.min(n - c, buf.length);
868868

869869
if (stringMode)

0 commit comments

Comments
 (0)