Browse Source

Remove dead code from js parser

greenkeeper-update-all
Ruben Bridgewater 9 years ago
parent
commit
5a2b54fd2f
  1. 41
      lib/parser/javascript.js

41
lib/parser/javascript.js

@ -55,19 +55,13 @@ ReplyParser.prototype._parseResult = function (type) {
}
if (type === 45) {
var result = this._buffer.toString(this._encoding, start, end);
return new Error(result);
}
if (this.options.return_buffers) {
return new Error(this._buffer.toString(this._encoding, start, end));
} else if (this.options.return_buffers) {
return this._buffer.slice(start, end);
} else {
if (end - start < 65536) { // completely arbitrary
return small_toString(this._buffer, start, end);
} else {
return this._buffer.toString(this._encoding, start, end);
}
} else if (end - start < 65536) { // completely arbitrary
return small_toString(this._buffer, start, end);
}
return this._buffer.toString(this._encoding, start, end);
} else if (type === 58) { // :
// up to the delimiter
end = this._packetEndOffset() - 1;
@ -92,7 +86,7 @@ ReplyParser.prototype._parseResult = function (type) {
// packets with a size of -1 are considered null
if (packetHeader.size === -1) {
return undefined;
return null;
}
end = this._offset + packetHeader.size;
@ -108,10 +102,9 @@ ReplyParser.prototype._parseResult = function (type) {
if (this.options.return_buffers) {
return this._buffer.slice(start, end);
} else {
return this._buffer.toString(this._encoding, start, end);
}
} else if (type === 42) { // *
return this._buffer.toString(this._encoding, start, end);
} else { // *
offset = this._offset;
packetHeader = new Packet(type, this.parseHeader());
@ -136,9 +129,6 @@ ReplyParser.prototype._parseResult = function (type) {
throw new IncompleteReadBuffer("Wait for more data.");
}
res = this._parseResult(ntype);
if (res === undefined) {
res = null;
}
reply.push(res);
}
@ -176,18 +166,8 @@ ReplyParser.prototype.execute = function (buffer) {
} else if (type === 36) { // $
ret = this._parseResult(type);
if (ret === null) {
break;
}
// check the state for what is the result of
// a -1, set it back up for a null reply
if (ret === undefined) {
ret = null;
}
this.send_reply(ret);
} else if (type === 42) { // *
} else if (type === 42) { // 42 *
// set a rewind point. if a failure occurs,
// wait for the next execute()/append() and try again
offset = this._offset - 1;
@ -199,9 +179,6 @@ ReplyParser.prototype.execute = function (buffer) {
} catch (err) {
// catch the error (not enough data), rewind, and wait
// for the next packet to appear
if (! (err instanceof IncompleteReadBuffer)) {
throw err;
}
this._offset = offset;
break;
}

Loading…
Cancel
Save