Skip to content

Commit 1c70ecb

Browse files
TrottMyles Borins
authored and
Myles Borins
committed
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 3814ad4 commit 1c70ecb

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
@@ -129,10 +129,10 @@ function readableAddChunk(stream, state, chunk, encoding, addToFront) {
129129
onEofChunk(stream, state);
130130
} else if (state.objectMode || chunk && chunk.length > 0) {
131131
if (state.ended && !addToFront) {
132-
var e = new Error('stream.push() after EOF');
132+
const e = new Error('stream.push() after EOF');
133133
stream.emit('error', e);
134134
} else if (state.endEmitted && addToFront) {
135-
var e = new Error('stream.unshift() after end event');
135+
const e = new Error('stream.unshift() after end event');
136136
stream.emit('error', e);
137137
} else {
138138
if (state.decoder && !addToFront && !encoding)
@@ -639,13 +639,13 @@ Readable.prototype.unpipe = function(dest) {
639639
state.pipesCount = 0;
640640
state.flowing = false;
641641

642-
for (var i = 0; i < len; i++)
642+
for (let i = 0; i < len; i++)
643643
dests[i].emit('unpipe', this);
644644
return this;
645645
}
646646

647647
// try to find the right one.
648-
var i = state.pipes.indexOf(dest);
648+
const i = state.pipes.indexOf(dest);
649649
if (i === -1)
650650
return this;
651651

@@ -846,7 +846,7 @@ function fromList(n, state) {
846846
if (n < list[0].length) {
847847
// just take a part of the first list item.
848848
// slice is the same for buffers and strings.
849-
var buf = list[0];
849+
const buf = list[0];
850850
ret = buf.slice(0, n);
851851
list[0] = buf.slice(n);
852852
} else if (n === list[0].length) {
@@ -862,7 +862,7 @@ function fromList(n, state) {
862862

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

868868
if (stringMode)

0 commit comments

Comments
 (0)