You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-07 13:22:56 +03:00
Make return_buffers work with ints
This commit is contained in:
@@ -37,7 +37,7 @@ function small_toString(buf, start, end) {
|
||||
|
||||
ReplyParser.prototype._parseResult = function (type) {
|
||||
var start, end, offset, packetHeader;
|
||||
|
||||
|
||||
if (type === 43 || type === 45) { // + or -
|
||||
// up to the delimiter
|
||||
end = this._packetEndOffset() - 1;
|
||||
@@ -73,6 +73,10 @@ ReplyParser.prototype._parseResult = function (type) {
|
||||
throw new Error("too far");
|
||||
}
|
||||
|
||||
if (this.options.return_buffers) {
|
||||
return this._buffer.slice(start, end);
|
||||
}
|
||||
|
||||
// return the coerced numeric value
|
||||
return +small_toString(this._buffer, start, end);
|
||||
} else if (type === 36) { // $
|
||||
@@ -177,7 +181,7 @@ ReplyParser.prototype.execute = function (buffer) {
|
||||
break;
|
||||
}
|
||||
|
||||
this.send_reply(+ret);
|
||||
this.send_reply(ret);
|
||||
} else if (type === 36) { // $
|
||||
ret = this._parseResult(type);
|
||||
|
||||
@@ -246,7 +250,7 @@ ReplyParser.prototype.append = function (newBuffer) {
|
||||
|
||||
this._buffer.copy(tmpBuffer, 0, this._offset);
|
||||
newBuffer.copy(tmpBuffer, remaining, 0);
|
||||
|
||||
|
||||
this._buffer = tmpBuffer;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user