summaryrefslogtreecommitdiff
path: root/lib/_stream_readable.js
diff options
context:
space:
mode:
authorRuben Bridgewater <ruben@bridgewater.de>2019-03-26 05:21:27 +0100
committerMichaël Zasso <targos@protonmail.com>2019-03-30 13:16:39 +0100
commitf86f5736da72ad4f3fb50692461222590e2f0258 (patch)
tree6fee263bfca24abbf76b7a3f1517b8184c29f077 /lib/_stream_readable.js
parentf0b3855a90bc5f68fe38ea5e7c69d30ae7d81a27 (diff)
downloadandroid-node-v8-f86f5736da72ad4f3fb50692461222590e2f0258.tar.gz
android-node-v8-f86f5736da72ad4f3fb50692461222590e2f0258.tar.bz2
android-node-v8-f86f5736da72ad4f3fb50692461222590e2f0258.zip
benchmark,lib: change var to const
Refs: https://github.com/nodejs/node/pull/26679 PR-URL: https://github.com/nodejs/node/pull/26915 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Refael Ackermann <refack@gmail.com>
Diffstat (limited to 'lib/_stream_readable.js')
-rw-r--r--lib/_stream_readable.js42
1 files changed, 21 insertions, 21 deletions
diff --git a/lib/_stream_readable.js b/lib/_stream_readable.js
index 81e8de310c..3e46a604e5 100644
--- a/lib/_stream_readable.js
+++ b/lib/_stream_readable.js
@@ -213,7 +213,7 @@ Readable.prototype._destroy = function(err, cb) {
// similar to how Writable.write() returns true if you should
// write() some more.
Readable.prototype.push = function(chunk, encoding) {
- var state = this._readableState;
+ const state = this._readableState;
var skipChunkCheck;
if (!state.objectMode) {
@@ -239,7 +239,7 @@ Readable.prototype.unshift = function(chunk) {
function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
debug('readableAddChunk', chunk);
- var state = stream._readableState;
+ const state = stream._readableState;
if (chunk === null) {
state.reading = false;
onEofChunk(stream, state);
@@ -383,8 +383,8 @@ function howMuchToRead(n, state) {
Readable.prototype.read = function(n) {
debug('read', n);
n = parseInt(n, 10);
- var state = this._readableState;
- var nOrig = n;
+ const state = this._readableState;
+ const nOrig = n;
if (n !== 0)
state.emittedReadable = false;
@@ -534,7 +534,7 @@ function onEofChunk(stream, state) {
// another read() call => stack overflow. This way, it might trigger
// a nextTick recursion warning, but that's not so bad.
function emitReadable(stream) {
- var state = stream._readableState;
+ const state = stream._readableState;
debug('emitReadable', state.needReadable, state.emittedReadable);
state.needReadable = false;
if (!state.emittedReadable) {
@@ -545,7 +545,7 @@ function emitReadable(stream) {
}
function emitReadable_(stream) {
- var state = stream._readableState;
+ const state = stream._readableState;
debug('emitReadable_', state.destroyed, state.length, state.ended);
if (!state.destroyed && (state.length || state.ended)) {
stream.emit('readable');
@@ -625,8 +625,8 @@ Readable.prototype._read = function(n) {
};
Readable.prototype.pipe = function(dest, pipeOpts) {
- var src = this;
- var state = this._readableState;
+ const src = this;
+ const state = this._readableState;
switch (state.pipesCount) {
case 0:
@@ -642,11 +642,11 @@ Readable.prototype.pipe = function(dest, pipeOpts) {
state.pipesCount += 1;
debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
- var doEnd = (!pipeOpts || pipeOpts.end !== false) &&
+ const doEnd = (!pipeOpts || pipeOpts.end !== false) &&
dest !== process.stdout &&
dest !== process.stderr;
- var endFn = doEnd ? onend : unpipe;
+ const endFn = doEnd ? onend : unpipe;
if (state.endEmitted)
process.nextTick(endFn);
else
@@ -672,7 +672,7 @@ Readable.prototype.pipe = function(dest, pipeOpts) {
// on the source. This would be more elegant with a .once()
// handler in flow(), but adding and removing repeatedly is
// too slow.
- var ondrain = pipeOnDrain(src);
+ const ondrain = pipeOnDrain(src);
dest.on('drain', ondrain);
var cleanedUp = false;
@@ -703,7 +703,7 @@ Readable.prototype.pipe = function(dest, pipeOpts) {
src.on('data', ondata);
function ondata(chunk) {
debug('ondata');
- var ret = dest.write(chunk);
+ const ret = dest.write(chunk);
debug('dest.write', ret);
if (ret === false) {
// If the user unpiped during `dest.write()`, it is possible
@@ -765,7 +765,7 @@ Readable.prototype.pipe = function(dest, pipeOpts) {
function pipeOnDrain(src) {
return function pipeOnDrainFunctionResult() {
- var state = src._readableState;
+ const state = src._readableState;
debug('pipeOnDrain', state.awaitDrain);
if (state.awaitDrain)
state.awaitDrain--;
@@ -778,8 +778,8 @@ function pipeOnDrain(src) {
Readable.prototype.unpipe = function(dest) {
- var state = this._readableState;
- var unpipeInfo = { hasUnpiped: false };
+ const state = this._readableState;
+ const unpipeInfo = { hasUnpiped: false };
// If we're not piping anywhere, then do nothing.
if (state.pipesCount === 0)
@@ -819,7 +819,7 @@ Readable.prototype.unpipe = function(dest) {
}
// Try to find the right one.
- var index = state.pipes.indexOf(dest);
+ const index = state.pipes.indexOf(dest);
if (index === -1)
return this;
@@ -920,7 +920,7 @@ function nReadingNextTick(self) {
// pause() and resume() are remnants of the legacy readable stream API
// If the user uses them, then switch into old mode.
Readable.prototype.resume = function() {
- var state = this._readableState;
+ const state = this._readableState;
if (!state.flowing) {
debug('resume');
// We flow only if there is no one listening
@@ -974,7 +974,7 @@ function flow(stream) {
// This is *not* part of the readable stream interface.
// It is an ugly unfortunate mess of history.
Readable.prototype.wrap = function(stream) {
- var state = this._readableState;
+ const state = this._readableState;
var paused = false;
stream.on('end', () => {
@@ -999,7 +999,7 @@ Readable.prototype.wrap = function(stream) {
else if (!state.objectMode && (!chunk || !chunk.length))
return;
- var ret = this.push(chunk);
+ const ret = this.push(chunk);
if (!ret) {
paused = true;
stream.pause();
@@ -1007,7 +1007,7 @@ Readable.prototype.wrap = function(stream) {
});
// Proxy all the other methods. Important when wrapping filters and duplexes.
- for (var i in stream) {
+ for (const i in stream) {
if (this[i] === undefined && typeof stream[i] === 'function') {
this[i] = function methodWrap(method) {
return function methodWrapReturnFunction() {
@@ -1122,7 +1122,7 @@ function fromList(n, state) {
}
function endReadable(stream) {
- var state = stream._readableState;
+ const state = stream._readableState;
debug('endReadable', state.endEmitted);
if (!state.endEmitted) {