@@ -63,13 +63,15 @@ function parseStringNumbers (parser) {
63
63
/**
64
64
* Returns a string or buffer of the provided offset start and
65
65
* end ranges. Checks `optionReturnBuffers`.
66
+ *
67
+ * If returnBuffers is active, all return values are returned as buffers besides numbers and errors
68
+ *
66
69
* @param parser
67
70
* @param start
68
71
* @param end
69
72
* @returns {* }
70
73
*/
71
74
function convertBufferRange ( parser , start , end ) {
72
- // If returnBuffers is active, all return values are returned as buffers besides numbers and errors
73
75
parser . offset = end + 2
74
76
if ( parser . optionReturnBuffers === true ) {
75
77
return parser . buffer . slice ( start , end )
@@ -111,13 +113,15 @@ function parseLength (parser) {
111
113
112
114
/**
113
115
* Parse a ':' redis integer response
116
+ *
117
+ * If stringNumbers is activated the parser always returns numbers as string
118
+ * This is important for big numbers (number > Math.pow(2, 53)) as js numbers
119
+ * are 64bit floating point numbers with reduced precision
120
+ *
114
121
* @param parser
115
122
* @returns {* }
116
123
*/
117
124
function parseInteger ( parser ) {
118
- // If stringNumbers is activated the parser always returns numbers as string
119
- // This is important for big numbers (number > Math.pow(2, 53)) as js numbers
120
- // are 64bit floating point numbers with reduced precision
121
125
if ( parser . optionStringNumbers ) {
122
126
return parseStringNumbers ( parser )
123
127
}
@@ -283,13 +287,17 @@ function JavascriptRedisParser (options) {
283
287
284
288
/**
285
289
* Concat a bulk string containing multiple chunks
290
+ *
291
+ * Notes:
292
+ * 1) The first chunk might contain the whole bulk string including the \r
293
+ * 2) We are only safe to fully add up elements that are neither the first nor any of the last two elements
294
+ *
286
295
* @param parser
287
296
* @param buffer
288
297
* @returns {String }
289
298
*/
290
299
function concatBulkString ( parser ) {
291
300
var list = parser . bufferCache
292
- // The first chunk might contain the whole bulk string including the \r
293
301
var chunks = list . length
294
302
var offset = parser . bigStrSize - parser . totalChunkSize
295
303
parser . offset = offset
@@ -302,7 +310,6 @@ function concatBulkString (parser) {
302
310
}
303
311
var res = decoder . write ( list [ 0 ] . slice ( parser . bigOffset ) )
304
312
for ( var i = 1 ; i < chunks - 2 ; i ++ ) {
305
- // We are only safe to fully add up elements that are neither the first nor any of the last two elements
306
313
res += decoder . write ( list [ i ] )
307
314
}
308
315
res += decoder . end ( list [ i ] . slice ( 0 , offset === 1 ? list [ i ] . length - 1 : offset - 2 ) )
@@ -377,7 +384,7 @@ function concatBuffer (parser, length) {
377
384
* @param buffer
378
385
* @returns {undefined }
379
386
*/
380
- JavascriptRedisParser . prototype . execute = function ( buffer ) {
387
+ JavascriptRedisParser . prototype . execute = function execute ( buffer ) {
381
388
if ( this . buffer === null ) {
382
389
this . buffer = buffer
383
390
this . offset = 0
@@ -418,9 +425,9 @@ JavascriptRedisParser.prototype.execute = function (buffer) {
418
425
}
419
426
420
427
if ( type === 45 ) {
421
- this . returnError ( response ) // Errors -
428
+ this . returnError ( response )
422
429
} else {
423
- this . returnReply ( response ) // Strings + // Integers : // Bulk strings $ // Arrays *
430
+ this . returnReply ( response )
424
431
}
425
432
}
426
433
0 commit comments