diff --git a/core/websock.js b/core/websock.js index 7b770d4b..b6891329 100644 --- a/core/websock.js +++ b/core/websock.js @@ -125,7 +125,6 @@ export default class Websock { } rQshiftStr(len) { - if (typeof(len) === 'undefined') { len = this._rQlen - this._rQi; } let str = ""; // Handle large arrays in steps to avoid long strings on the stack for (let i = 0; i < len; i += 4096) { @@ -136,20 +135,17 @@ export default class Websock { } rQshiftBytes(len) { - if (typeof(len) === 'undefined') { len = this._rQlen - this._rQi; } this._rQi += len; return new Uint8Array(this._rQ.buffer, this._rQi - len, len); } rQshiftTo(target, len) { - if (len === undefined) { len = this._rQlen - this._rQi; } // TODO: make this just use set with views when using a ArrayBuffer to store the rQ target.set(new Uint8Array(this._rQ.buffer, this._rQi, len)); this._rQi += len; } rQpeekBytes(len) { - if (typeof(len) === 'undefined') { len = this._rQlen - this._rQi; } return new Uint8Array(this._rQ.buffer, this._rQi, len); } diff --git a/tests/test.websock.js b/tests/test.websock.js index 91f69865..2034bd6e 100644 --- a/tests/test.websock.js +++ b/tests/test.websock.js @@ -67,11 +67,6 @@ describe('Websock', function () { expect(sock._rQlen - sock._rQi).to.equal(befLen - 3); }); - it('should shift the entire rest of the queue off if no length is given', function () { - sock.rQshiftStr(); - expect(sock._rQlen - sock._rQi).to.equal(0); - }); - it('should be able to handle very large strings', function () { const BIG_LEN = 500000; const RQ_BIG = new Uint8Array(BIG_LEN); @@ -90,7 +85,7 @@ describe('Websock', function () { sock._rQ.set(RQ_BIG); sock._rQlen = RQ_BIG.length; - const shifted = sock.rQshiftStr(); + const shifted = sock.rQshiftStr(BIG_LEN); expect(shifted).to.be.equal(expected); expect(sock._rQlen - sock._rQi).to.equal(0); @@ -106,11 +101,6 @@ describe('Websock', function () { expect(shifted).to.array.equal(new Uint8Array(RQ_TEMPLATE.buffer, befRQi, 3)); expect(sock._rQlen - sock._rQi).to.equal(befLen - 3); }); - - it('should shift the entire rest of the queue off if no length is given', function () { - sock.rQshiftBytes(); - expect(sock._rQlen - sock._rQi).to.equal(0); - }); }); describe('rQpeekBytes', function () { @@ -130,12 +120,6 @@ describe('Websock', function () { expect(sl).to.array.equal(new Uint8Array(RQ_TEMPLATE.buffer, 0, 2)); }); - it('should use the rest of the receive queue if no end is given', function () { - const sl = sock.rQpeekBytes(); - expect(sl).to.have.length(RQ_TEMPLATE.length); - expect(sl).to.array.equal(RQ_TEMPLATE); - }); - it('should take the current rQi in to account', function () { sock._rQi = 1; expect(sock.rQpeekBytes(2)).to.array.equal(new Uint8Array(RQ_TEMPLATE.buffer, 1, 2));