From f86f5736da72ad4f3fb50692461222590e2f0258 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Tue, 26 Mar 2019 05:21:27 +0100 Subject: benchmark,lib: change var to const MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refs: https://github.com/nodejs/node/pull/26679 PR-URL: https://github.com/nodejs/node/pull/26915 Reviewed-By: Michaël Zasso Reviewed-By: Tobias Nießen Reviewed-By: Refael Ackermann --- lib/_stream_readable.js | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'lib/_stream_readable.js') 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) { -- cgit v1.2.3