File tree Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -789,19 +789,18 @@ protoGetter('_bytesDispatched', function _bytesDispatched() {
789
789
790
790
protoGetter ( 'bytesWritten' , function bytesWritten ( ) {
791
791
let bytes = this . _bytesDispatched ;
792
- const state = this . _writableState ;
793
792
const data = this . _pendingData ;
794
793
const encoding = this . _pendingEncoding ;
794
+ const writableBuffer = this . writableBuffer ;
795
795
796
- if ( ! state )
796
+ if ( ! writableBuffer )
797
797
return undefined ;
798
798
799
- this . writableBuffer . forEach ( function ( el ) {
800
- if ( el . chunk instanceof Buffer )
801
- bytes += el . chunk . length ;
802
- else
803
- bytes += Buffer . byteLength ( el . chunk , el . encoding ) ;
804
- } ) ;
799
+ for ( const el of writableBuffer ) {
800
+ bytes += el . chunk instanceof Buffer ?
801
+ el . chunk . length :
802
+ Buffer . byteLength ( el . chunk , el . encoding ) ;
803
+ }
805
804
806
805
if ( ArrayIsArray ( data ) ) {
807
806
// Was a writev, iterate over chunks to get total length
You can’t perform that action at this time.
0 commit comments