Skip to content

Commit

Permalink
lib: change var to let/const
Browse files Browse the repository at this point in the history
PR-URL: #32037
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
himself65 authored and BridgeAR committed Mar 17, 2020
1 parent 0594de4 commit 055b3b9
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions lib/_stream_writable.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ function WritableState(options, stream, isDuplex) {
}

WritableState.prototype.getBuffer = function getBuffer() {
var current = this.bufferedRequest;
let current = this.bufferedRequest;
const out = [];
while (current) {
out.push(current);
Expand All @@ -205,7 +205,7 @@ ObjectDefineProperty(WritableState.prototype, 'buffer', {

// Test _writableState for inheritance to account for Duplex streams,
// whose prototype chain only points to Readable.
var realHasInstance;
let realHasInstance;
if (typeof Symbol === 'function' && SymbolHasInstance) {
realHasInstance = FunctionPrototype[SymbolHasInstance];
ObjectDefineProperty(Writable, SymbolHasInstance, {
Expand Down Expand Up @@ -357,7 +357,7 @@ function writeOrBuffer(stream, state, chunk, encoding, cb) {
state.needDrain = true;

if (state.writing || state.corked || state.errored) {
var last = state.lastBufferedRequest;
const last = state.lastBufferedRequest;
state.lastBufferedRequest = {
chunk,
encoding,
Expand Down Expand Up @@ -428,7 +428,7 @@ function onwrite(stream, er) {
}
} else {
// Check if we're actually ready to finish, but don't emit yet
var finished = needFinish(state) || stream.destroyed;
const finished = needFinish(state) || stream.destroyed;

if (!finished &&
!state.corked &&
Expand Down Expand Up @@ -499,17 +499,17 @@ function errorBuffer(state, err) {
// If there's something in the buffer waiting, then process it
function clearBuffer(stream, state) {
state.bufferProcessing = true;
var entry = state.bufferedRequest;
let entry = state.bufferedRequest;

if (stream._writev && entry && entry.next) {
// Fast case, write everything using _writev()
var l = state.bufferedRequestCount;
var buffer = new Array(l);
var holder = state.corkedRequestsFree;
const l = state.bufferedRequestCount;
const buffer = new Array(l);
const holder = state.corkedRequestsFree;
holder.entry = entry;

var count = 0;
var allBuffers = true;
let count = 0;
let allBuffers = true;
while (entry) {
buffer[count] = entry;
if (entry.encoding !== 'buffer')
Expand All @@ -529,18 +529,18 @@ function clearBuffer(stream, state) {
state.corkedRequestsFree = holder.next;
holder.next = null;
} else {
var corkReq = { next: null, entry: null, finish: undefined };
const corkReq = { next: null, entry: null, finish: undefined };
corkReq.finish = onCorkedFinish.bind(undefined, corkReq, state);
state.corkedRequestsFree = corkReq;
}
state.bufferedRequestCount = 0;
} else {
// Slow case, write chunks one-by-one
while (entry) {
var chunk = entry.chunk;
var encoding = entry.encoding;
var cb = entry.callback;
var len = state.objectMode ? 1 : chunk.length;
const chunk = entry.chunk;
const encoding = entry.encoding;
const cb = entry.callback;
const len = state.objectMode ? 1 : chunk.length;

doWrite(stream, state, false, len, chunk, encoding, cb);
entry = entry.next;
Expand Down Expand Up @@ -677,10 +677,10 @@ function endWritable(stream, state, cb) {
}

function onCorkedFinish(corkReq, state, err) {
var entry = corkReq.entry;
let entry = corkReq.entry;
corkReq.entry = null;
while (entry) {
var cb = entry.callback;
const cb = entry.callback;
state.pendingcb--;
cb(err);
entry = entry.next;
Expand Down

0 comments on commit 055b3b9

Please sign in to comment.