diff options
author | Ruben Bridgewater <ruben@bridgewater.de> | 2019-03-26 05:21:27 +0100 |
---|---|---|
committer | Michaël Zasso <targos@protonmail.com> | 2019-03-30 13:16:39 +0100 |
commit | f86f5736da72ad4f3fb50692461222590e2f0258 (patch) | |
tree | 6fee263bfca24abbf76b7a3f1517b8184c29f077 /lib/_stream_writable.js | |
parent | f0b3855a90bc5f68fe38ea5e7c69d30ae7d81a27 (diff) | |
download | android-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_writable.js')
-rw-r--r-- | lib/_stream_writable.js | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/lib/_stream_writable.js b/lib/_stream_writable.js index 486d044cb0..7f9eeb6793 100644 --- a/lib/_stream_writable.js +++ b/lib/_stream_writable.js @@ -93,7 +93,7 @@ function WritableState(options, stream, isDuplex) { // Should we decode strings into buffers before passing to _write? // this is here so that some node-core streams can optimize string // handling at a lower level. - var noDecode = options.decodeStrings === false; + const noDecode = options.decodeStrings === false; this.decodeStrings = !noDecode; // Crypto is kind of old and crusty. Historically, its default string @@ -157,14 +157,14 @@ function WritableState(options, stream, isDuplex) { // Allocate the first CorkedRequest, there is always // one allocated and free to use, and we maintain at most two - var corkReq = { next: null, entry: null, finish: undefined }; + const corkReq = { next: null, entry: null, finish: undefined }; corkReq.finish = onCorkedFinish.bind(undefined, corkReq, this); this.corkedRequestsFree = corkReq; } WritableState.prototype.getBuffer = function getBuffer() { var current = this.bufferedRequest; - var out = []; + const out = []; while (current) { out.push(current); current = current.next; @@ -245,7 +245,7 @@ Writable.prototype.pipe = function() { function writeAfterEnd(stream, cb) { - var er = new ERR_STREAM_WRITE_AFTER_END(); + const er = new ERR_STREAM_WRITE_AFTER_END(); // TODO: defer error events consistently everywhere, not just the cb errorOrDestroy(stream, er); process.nextTick(cb, er); @@ -271,9 +271,9 @@ function validChunk(stream, state, chunk, cb) { } Writable.prototype.write = function(chunk, encoding, cb) { - var state = this._writableState; + const state = this._writableState; var ret = false; - var isBuf = !state.objectMode && Stream._isUint8Array(chunk); + const isBuf = !state.objectMode && Stream._isUint8Array(chunk); if (isBuf && Object.getPrototypeOf(chunk) !== Buffer.prototype) { chunk = Stream._uint8ArrayToBuffer(chunk); @@ -307,7 +307,7 @@ Writable.prototype.cork = function() { }; Writable.prototype.uncork = function() { - var state = this._writableState; + const state = this._writableState; if (state.corked) { state.corked--; @@ -371,11 +371,11 @@ function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) { chunk = newChunk; } } - var len = state.objectMode ? 1 : chunk.length; + const len = state.objectMode ? 1 : chunk.length; state.length += len; - var ret = state.length < state.highWaterMark; + const ret = state.length < state.highWaterMark; // We must ensure that previous needDrain will not be reset to false. if (!ret) state.needDrain = true; @@ -448,9 +448,9 @@ function onwriteStateUpdate(state) { } function onwrite(stream, er) { - var state = stream._writableState; - var sync = state.sync; - var cb = state.writecb; + const state = stream._writableState; + const sync = state.sync; + const cb = state.writecb; if (typeof cb !== 'function') throw new ERR_MULTIPLE_CALLBACK(); @@ -569,7 +569,7 @@ Writable.prototype._write = function(chunk, encoding, cb) { Writable.prototype._writev = null; Writable.prototype.end = function(chunk, encoding, cb) { - var state = this._writableState; + const state = this._writableState; if (typeof chunk === 'function') { cb = chunk; @@ -638,7 +638,7 @@ function prefinish(stream, state) { } function finishMaybe(stream, state) { - var need = needFinish(state); + const need = needFinish(state); if (need) { prefinish(stream, state); if (state.pendingcb === 0) { |