Skip to content

Commit c216961

Browse files
author
Ruben Bridgewater
committed
Move comments out of functions
1 parent ff26377 commit c216961

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

lib/parser.js

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,15 @@ function parseStringNumbers (parser) {
6363
/**
6464
* Returns a string or buffer of the provided offset start and
6565
* end ranges. Checks `optionReturnBuffers`.
66+
*
67+
* If returnBuffers is active, all return values are returned as buffers besides numbers and errors
68+
*
6669
* @param parser
6770
* @param start
6871
* @param end
6972
* @returns {*}
7073
*/
7174
function convertBufferRange (parser, start, end) {
72-
// If returnBuffers is active, all return values are returned as buffers besides numbers and errors
7375
parser.offset = end + 2
7476
if (parser.optionReturnBuffers === true) {
7577
return parser.buffer.slice(start, end)
@@ -111,13 +113,15 @@ function parseLength (parser) {
111113

112114
/**
113115
* 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+
*
114121
* @param parser
115122
* @returns {*}
116123
*/
117124
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
121125
if (parser.optionStringNumbers) {
122126
return parseStringNumbers(parser)
123127
}
@@ -283,13 +287,17 @@ function JavascriptRedisParser (options) {
283287

284288
/**
285289
* 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+
*
286295
* @param parser
287296
* @param buffer
288297
* @returns {String}
289298
*/
290299
function concatBulkString (parser) {
291300
var list = parser.bufferCache
292-
// The first chunk might contain the whole bulk string including the \r
293301
var chunks = list.length
294302
var offset = parser.bigStrSize - parser.totalChunkSize
295303
parser.offset = offset
@@ -302,7 +310,6 @@ function concatBulkString (parser) {
302310
}
303311
var res = decoder.write(list[0].slice(parser.bigOffset))
304312
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
306313
res += decoder.write(list[i])
307314
}
308315
res += decoder.end(list[i].slice(0, offset === 1 ? list[i].length - 1 : offset - 2))
@@ -377,7 +384,7 @@ function concatBuffer (parser, length) {
377384
* @param buffer
378385
* @returns {undefined}
379386
*/
380-
JavascriptRedisParser.prototype.execute = function (buffer) {
387+
JavascriptRedisParser.prototype.execute = function execute (buffer) {
381388
if (this.buffer === null) {
382389
this.buffer = buffer
383390
this.offset = 0
@@ -418,9 +425,9 @@ JavascriptRedisParser.prototype.execute = function (buffer) {
418425
}
419426

420427
if (type === 45) {
421-
this.returnError(response) // Errors -
428+
this.returnError(response)
422429
} else {
423-
this.returnReply(response) // Strings + // Integers : // Bulk strings $ // Arrays *
430+
this.returnReply(response)
424431
}
425432
}
426433

0 commit comments

Comments
 (0)