Commit 2a84459 1 parent 3bfca0b commit 2a84459 Copy full SHA for 2a84459
File tree 1 file changed +10
-10
lines changed
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 {
71
71
72
72
// Consumes a specified amount of bytes or characters from the buffered data.
73
73
consume ( n , hasStrings ) {
74
- var ret ;
75
- if ( n < this . head . data . length ) {
74
+ const data = this . head . data ;
75
+ if ( n < data . length ) {
76
76
// `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 ) {
80
82
// 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 ( ) ;
85
84
}
86
- return ret ;
85
+ // Result spans more than one buffer.
86
+ return hasStrings ? this . _getString ( n ) : this . _getBuffer ( n ) ;
87
87
}
88
88
89
89
first ( ) {
You can’t perform that action at this time.
0 commit comments