1
0
Fork 0
mirror of https://github.com/codedread/bitjs synced 2025-10-05 18:34:17 +02:00

Make skip() return the ByteStream, for chaining. Document the tee() method.

This commit is contained in:
Jeff Schiller 2024-01-04 22:39:25 +09:00
parent b72e629d8a
commit 208b69a65d
3 changed files with 29 additions and 5 deletions

View file

@ -219,6 +219,11 @@ describe('bitjs.io.ByteStream', () => {
expect(stream.readNumber(1)).equals(3);
});
it('returns itself', () => {
const retVal = stream.skip(2);
expect(stream === retVal).equals(true);
});
it('skip(0) has no effect', () => {
stream.skip(0);
expect(stream.getNumBytesRead()).equals(0);
@ -256,6 +261,7 @@ describe('bitjs.io.ByteStream', () => {
stream.push(anotherArray.buffer);
const teed = stream.tee();
expect(teed !== stream).equals(true);
teed.readBytes(5);
expect(stream.getNumBytesLeft()).equals(8);
expect(teed.getNumBytesLeft()).equals(3);