@@ -187,7 +187,7 @@ function WritableState(options, stream, isDuplex) {
187187}
188188
189189WritableState . prototype . getBuffer = function getBuffer ( ) {
190- var current = this . bufferedRequest ;
190+ let current = this . bufferedRequest ;
191191const out = [ ] ;
192192while ( current ) {
193193out . push ( current ) ;
@@ -205,7 +205,7 @@ ObjectDefineProperty(WritableState.prototype, 'buffer', {
205205
206206// Test _writableState for inheritance to account for Duplex streams,
207207// whose prototype chain only points to Readable.
208- var realHasInstance ;
208+ let realHasInstance ;
209209if ( typeof Symbol === 'function' && SymbolHasInstance ) {
210210realHasInstance = FunctionPrototype [ SymbolHasInstance ] ;
211211ObjectDefineProperty ( Writable , SymbolHasInstance , {
@@ -357,7 +357,7 @@ function writeOrBuffer(stream, state, chunk, encoding, cb) {
357357state . needDrain = true ;
358358
359359if ( state . writing || state . corked || state . errored ) {
360- var last = state . lastBufferedRequest ;
360+ const last = state . lastBufferedRequest ;
361361state . lastBufferedRequest = {
362362 chunk,
363363 encoding,
@@ -428,7 +428,7 @@ function onwrite(stream, er) {
428428}
429429} else {
430430// Check if we're actually ready to finish, but don't emit yet
431- var finished = needFinish ( state ) || stream . destroyed ;
431+ const finished = needFinish ( state ) || stream . destroyed ;
432432
433433if ( ! finished &&
434434! state . corked &&
@@ -499,17 +499,17 @@ function errorBuffer(state, err) {
499499// If there's something in the buffer waiting, then process it
500500function clearBuffer ( stream , state ) {
501501state . bufferProcessing = true ;
502- var entry = state . bufferedRequest ;
502+ let entry = state . bufferedRequest ;
503503
504504if ( stream . _writev && entry && entry . next ) {
505505// Fast case, write everything using _writev()
506- var l = state . bufferedRequestCount ;
507- var buffer = new Array ( l ) ;
508- var holder = state . corkedRequestsFree ;
506+ const l = state . bufferedRequestCount ;
507+ const buffer = new Array ( l ) ;
508+ const holder = state . corkedRequestsFree ;
509509holder . entry = entry ;
510510
511- var count = 0 ;
512- var allBuffers = true ;
511+ let count = 0 ;
512+ let allBuffers = true ;
513513while ( entry ) {
514514buffer [ count ] = entry ;
515515if ( entry . encoding !== 'buffer' )
@@ -529,18 +529,18 @@ function clearBuffer(stream, state) {
529529state . corkedRequestsFree = holder . next ;
530530holder . next = null ;
531531} else {
532- var corkReq = { next : null , entry : null , finish : undefined } ;
532+ const corkReq = { next : null , entry : null , finish : undefined } ;
533533corkReq . finish = onCorkedFinish . bind ( undefined , corkReq , state ) ;
534534state . corkedRequestsFree = corkReq ;
535535}
536536state . bufferedRequestCount = 0 ;
537537} else {
538538// Slow case, write chunks one-by-one
539539while ( entry ) {
540- var chunk = entry . chunk ;
541- var encoding = entry . encoding ;
542- var cb = entry . callback ;
543- var len = state . objectMode ? 1 : chunk . length ;
540+ const chunk = entry . chunk ;
541+ const encoding = entry . encoding ;
542+ const cb = entry . callback ;
543+ const len = state . objectMode ? 1 : chunk . length ;
544544
545545doWrite ( stream , state , false , len , chunk , encoding , cb ) ;
546546entry = entry . next ;
@@ -677,10 +677,10 @@ function endWritable(stream, state, cb) {
677677}
678678
679679function onCorkedFinish ( corkReq , state , err ) {
680- var entry = corkReq . entry ;
680+ let entry = corkReq . entry ;
681681corkReq . entry = null ;
682682while ( entry ) {
683- var cb = entry . callback ;
683+ const cb = entry . callback ;
684684state . pendingcb -- ;
685685cb ( err ) ;
686686entry = entry . next ;
0 commit comments