File tree Expand file tree Collapse file tree 1 file changed +10
-10
lines changed Expand file tree Collapse file tree 1 file changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -71,19 +71,19 @@ module.exports = class BufferList {
7171
7272 // Consumes a specified amount of bytes or characters from the buffered data.
7373 consume ( n , hasStrings ) {
74- var ret ;
75- if ( n < this . head . data . length ) {
74+ const data = this . head . data ;
75+ if ( n < data . length ) {
7676 // `slice` is the same for buffers and strings.
77- ret = this . head . data . slice ( 0 , n ) ;
78- this . head . data = this . head . data . slice ( n ) ;
79- } else if ( n === this . head . data . length ) {
77+ const slice = data . slice ( 0 , n ) ;
78+ this . head . data = data . slice ( n ) ;
79+ return slice ;
80+ }
81+ if ( n === data . length ) {
8082 // First chunk is a perfect match.
81- ret = this . shift ( ) ;
82- } else {
83- // Result spans more than one buffer.
84- ret = hasStrings ? this . _getString ( n ) : this . _getBuffer ( n ) ;
83+ return this . shift ( ) ;
8584 }
86- return ret ;
85+ // Result spans more than one buffer.
86+ return hasStrings ? this . _getString ( n ) : this . _getBuffer ( n ) ;
8787 }
8888
8989 first ( ) {
You can’t perform that action at this time.
0 commit comments