parser: support Uint8Array's

This commit is contained in:
Fedor Indutny 2014-05-12 20:54:51 +04:00
parent 9874073510
commit 3b2fd8e168

View File

@ -38,6 +38,8 @@ Parser.prototype.feed = function feed(data) {
len = utils.copy(this.pending[0], chunk, off);
if (len === this.pending[0].length)
this.pending.shift();
else if (!this.pending[0].slice && this.pending[0] instanceof Uint8Array)
this.pending[0] = new Uint8Array(this.pending[0].buffer.slice(len));
else
this.pending[0] = this.pending[0].slice(len);
off += len;