@@ -190,7 +190,7 @@ function WritableState(options, stream, isDuplex) {
190
190
}
191
191
192
192
WritableState . prototype . getBuffer = function getBuffer ( ) {
193
- var current = this . bufferedRequest ;
193
+ let current = this . bufferedRequest ;
194
194
const out = [ ] ;
195
195
while ( current ) {
196
196
out . push ( current ) ;
@@ -201,7 +201,7 @@ WritableState.prototype.getBuffer = function getBuffer() {
201
201
202
202
// Test _writableState for inheritance to account for Duplex streams,
203
203
// whose prototype chain only points to Readable.
204
- var realHasInstance ;
204
+ let realHasInstance ;
205
205
if ( typeof Symbol === 'function' && SymbolHasInstance ) {
206
206
realHasInstance = FunctionPrototype [ SymbolHasInstance ] ;
207
207
ObjectDefineProperty ( Writable , SymbolHasInstance , {
@@ -351,7 +351,7 @@ function writeOrBuffer(stream, state, chunk, encoding, cb) {
351
351
state . needDrain = true ;
352
352
353
353
if ( state . writing || state . corked || state . errored ) {
354
- var last = state . lastBufferedRequest ;
354
+ const last = state . lastBufferedRequest ;
355
355
state . lastBufferedRequest = {
356
356
chunk,
357
357
encoding,
@@ -424,7 +424,7 @@ function onwrite(stream, er) {
424
424
}
425
425
} else {
426
426
// Check if we're actually ready to finish, but don't emit yet
427
- var finished = needFinish ( state ) || stream . destroyed ;
427
+ const finished = needFinish ( state ) || stream . destroyed ;
428
428
429
429
if ( ! finished &&
430
430
! state . corked &&
@@ -495,17 +495,17 @@ function errorBuffer(state, err) {
495
495
// If there's something in the buffer waiting, then process it
496
496
function clearBuffer ( stream , state ) {
497
497
state . bufferProcessing = true ;
498
- var entry = state . bufferedRequest ;
498
+ let entry = state . bufferedRequest ;
499
499
500
500
if ( stream . _writev && entry && entry . next ) {
501
501
// Fast case, write everything using _writev()
502
- var l = state . bufferedRequestCount ;
503
- var buffer = new Array ( l ) ;
504
- var holder = state . corkedRequestsFree ;
502
+ const l = state . bufferedRequestCount ;
503
+ const buffer = new Array ( l ) ;
504
+ const holder = state . corkedRequestsFree ;
505
505
holder . entry = entry ;
506
506
507
- var count = 0 ;
508
- var allBuffers = true ;
507
+ let count = 0 ;
508
+ let allBuffers = true ;
509
509
while ( entry ) {
510
510
buffer [ count ] = entry ;
511
511
if ( entry . encoding !== 'buffer' )
@@ -525,18 +525,18 @@ function clearBuffer(stream, state) {
525
525
state . corkedRequestsFree = holder . next ;
526
526
holder . next = null ;
527
527
} else {
528
- var corkReq = { next : null , entry : null , finish : undefined } ;
528
+ const corkReq = { next : null , entry : null , finish : undefined } ;
529
529
corkReq . finish = onCorkedFinish . bind ( undefined , corkReq , state ) ;
530
530
state . corkedRequestsFree = corkReq ;
531
531
}
532
532
state . bufferedRequestCount = 0 ;
533
533
} else {
534
534
// Slow case, write chunks one-by-one
535
535
while ( entry ) {
536
- var chunk = entry . chunk ;
537
- var encoding = entry . encoding ;
538
- var cb = entry . callback ;
539
- var len = state . objectMode ? 1 : chunk . length ;
536
+ const chunk = entry . chunk ;
537
+ const encoding = entry . encoding ;
538
+ const cb = entry . callback ;
539
+ const len = state . objectMode ? 1 : chunk . length ;
540
540
541
541
doWrite ( stream , state , false , len , chunk , encoding , cb ) ;
542
542
entry = entry . next ;
@@ -692,10 +692,10 @@ function endWritable(stream, state, cb) {
692
692
}
693
693
694
694
function onCorkedFinish ( corkReq , state , err ) {
695
- var entry = corkReq . entry ;
695
+ let entry = corkReq . entry ;
696
696
corkReq . entry = null ;
697
697
while ( entry ) {
698
- var cb = entry . callback ;
698
+ const cb = entry . callback ;
699
699
state . pendingcb -- ;
700
700
cb ( err ) ;
701
701
entry = entry . next ;
0 commit comments