Skip to content

Commit 2825df0

Browse files
committed
Fix bug with ByteStream.skip(0) not returning itself
1 parent 2b772f8 commit 2825df0

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

io/bytestream.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ export class ByteStream {
317317
if (n !== num || num < 0) {
318318
throw 'Error! Called skip() with a non-positive integer';
319319
} else if (num === 0) {
320-
return;
320+
return this;
321321
}
322322

323323
const totalBytesLeft = this.getNumBytesLeft();

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@codedread/bitjs",
3-
"version": "1.2.0",
3+
"version": "1.2.1",
44
"description": "Binary Tools for JavaScript",
55
"homepage": "https://github.com/codedread/bitjs",
66
"author": "Jeff Schiller",

tests/io-bytestream.spec.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,10 +239,11 @@ describe('bitjs.io.ByteStream', () => {
239239
});
240240

241241
it('skip(0) has no effect', () => {
242-
stream.skip(0);
242+
const retVal = stream.skip(0);
243243
expect(stream.getNumBytesRead()).equals(0);
244244
expect(stream.getNumBytesLeft()).equals(4);
245245
expect(stream.readNumber(1)).equals(0);
246+
expect(retVal === stream).equals(true);
246247
});
247248

248249
it('skip() with negative throws an error', () => {

0 commit comments

Comments
 (0)