File tree Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -115,14 +115,22 @@ function parseSimpleString (parser) {
115
115
}
116
116
117
117
/**
118
- * Returns the string length via parseSimpleNumbers
118
+ * Returns the read length
119
119
* @param parser
120
120
* @returns {* }
121
121
*/
122
122
function parseLength ( parser ) {
123
- const string = parseSimpleNumbers ( parser )
124
- if ( string !== undefined ) {
125
- return string
123
+ const length = parser . buffer . length - 1
124
+ var offset = parser . offset
125
+ var number = 0
126
+
127
+ while ( offset < length ) {
128
+ const c1 = parser . buffer [ offset ++ ]
129
+ if ( c1 === 13 ) {
130
+ parser . offset = offset + 1
131
+ return number
132
+ }
133
+ number = ( number * 10 ) + ( c1 - 48 )
126
134
}
127
135
}
128
136
Original file line number Diff line number Diff line change @@ -195,7 +195,7 @@ describe('parsers', function () {
195
195
assert . strictEqual ( replyCount , 6 )
196
196
parser . execute ( Buffer . from ( '$-5' ) )
197
197
assert . strictEqual ( replyCount , 6 )
198
- parser . execute ( Buffer . from ( '\r\n:12345\r\n*- \r\n*-1\r\n+t\r\n' ) )
198
+ parser . execute ( Buffer . from ( '\r\n:12345\r\n*0 \r\n*-1\r\n+t\r\n' ) )
199
199
assert . strictEqual ( replyCount , 11 )
200
200
} )
201
201
You can’t perform that action at this time.
0 commit comments