diff --git a/lib/parser/javascript.js b/lib/parser/javascript.js index 1c1c41064c..b35fd84dde 100644 --- a/lib/parser/javascript.js +++ b/lib/parser/javascript.js @@ -126,7 +126,7 @@ FasterReplyParser.prototype._parseResult = function (type) { FasterReplyParser.prototype.execute = function (buffer) { this.append(buffer); - + var type; while (true) { var offset = this._offset; try { @@ -137,20 +137,33 @@ FasterReplyParser.prototype.execute = function (buffer) { break; } - var type = this._buffer[this._offset++]; + type = this._buffer[this._offset++]; + if (type === 43) { // + ret = this._parseResult(type); + if (ret === null) { + break; + } this.send_reply(ret); } else if (type === 45) { // - ret = this._parseResult(type); + if (ret === null) { + break; + } this.send_error(ret); } else if (type === 58) { // : ret = this._parseResult(type); + if (ret === null) { + break; + } this.send_reply(+ret); } else if (type === 36) { // $ ret = this._parseResult(type); + if (ret === null) { + break; + } this.send_reply(ret); } else if (type === 42) { // * // set a rewind point. if a failure occurs, @@ -167,8 +180,8 @@ FasterReplyParser.prototype.execute = function (buffer) { } catch(err) { // catch the error (not enough data), rewind, and wait // for the next packet to appear - this._offset = offset; - break; + this._offset = offset; + break; } } }; @@ -207,6 +220,7 @@ FasterReplyParser.prototype.append = function(newBuffer) { this._buffer = tmpBuffer; } + this._offset = 0; }; @@ -245,7 +259,7 @@ FasterReplyParser.prototype.parser_error = function (message) { FasterReplyParser.prototype.send_error = function (reply) { this.emit("reply error", reply); }; - +var count = 0; FasterReplyParser.prototype.send_reply = function (reply) { this.emit("reply", reply); }; \ No newline at end of file