diff --git a/lib/_stream_writable.js b/lib/_stream_writable.js index af199956062d67..ced41e9ab9562f 100644 --- a/lib/_stream_writable.js +++ b/lib/_stream_writable.js @@ -190,7 +190,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); @@ -201,7 +201,7 @@ WritableState.prototype.getBuffer = function getBuffer() { // 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, { @@ -351,7 +351,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, @@ -424,7 +424,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 && @@ -495,17 +495,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') @@ -525,7 +525,7 @@ 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; } @@ -533,10 +533,10 @@ function clearBuffer(stream, state) { } 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; @@ -692,10 +692,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;