Skip to content

Commit

Permalink
stream: refactor redeclared variables
Browse files Browse the repository at this point in the history
`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 <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information
Trott authored and Myles Borins committed Feb 18, 2016
1 parent 8c4903d commit 538c475
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/_stream_readable.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,10 @@ function readableAddChunk(stream, state, chunk, encoding, addToFront) {
onEofChunk(stream, state);
} else if (state.objectMode || chunk && chunk.length > 0) {
if (state.ended && !addToFront) {
var e = new Error('stream.push() after EOF');
const e = new Error('stream.push() after EOF');
stream.emit('error', e);
} else if (state.endEmitted && addToFront) {
var e = new Error('stream.unshift() after end event');
const e = new Error('stream.unshift() after end event');
stream.emit('error', e);
} else {
if (state.decoder && !addToFront && !encoding)
Expand Down Expand Up @@ -639,13 +639,13 @@ Readable.prototype.unpipe = function(dest) {
state.pipesCount = 0;
state.flowing = false;

for (var i = 0; i < len; i++)
for (let i = 0; i < len; i++)
dests[i].emit('unpipe', this);
return this;
}

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

Expand Down Expand Up @@ -846,7 +846,7 @@ function fromList(n, state) {
if (n < list[0].length) {
// just take a part of the first list item.
// slice is the same for buffers and strings.
var buf = list[0];
const buf = list[0];
ret = buf.slice(0, n);
list[0] = buf.slice(n);
} else if (n === list[0].length) {
Expand All @@ -862,7 +862,7 @@ function fromList(n, state) {

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

if (stringMode)
Expand Down

0 comments on commit 538c475

Please sign in to comment.