Skip to content

Commit

Permalink
Fix prebuffer storage length (#252)
Browse files Browse the repository at this point in the history
* Fix prebuffer storage length #160

* up version

Co-authored-by: Grigory Gorshkov <[email protected]>
  • Loading branch information
ch1ller0 and Grigory Gorshkov authored Apr 13, 2021
1 parent 1112ceb commit 50472b7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@fridgefm/radio-core",
"author": "Grigory Gorshkov",
"version": "3.0.1",
"version": "3.0.2",
"description": "internet radio engine made on NodeJS platform",
"license": "MIT",
"main": "./lib/index.js",
Expand Down
2 changes: 1 addition & 1 deletion src/features/Prebuffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class Prebuffer {

public modify(chunks: Buffer[]) {
chunks.forEach((ch) => {
if (this._storage.length > this._prebufferLength) {
if (this._storage.length >= this._prebufferLength) {
this._storage.shift();
}

Expand Down
4 changes: 2 additions & 2 deletions src/features/__tests__/Prebuffer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ describe('features/Prebuffer', () => {

// overflow - the length stays the same
instance.modify(createChunks('1234'));
expect(instance.getStorage().join('')).toEqual('4567890123');
expect(instance.getStorage().join('')).toEqual('5678901234');

instance.modify(createChunks('1234'));
expect(instance.getStorage().join('')).toEqual('8901234123');
expect(instance.getStorage().join('')).toEqual('9012341234');
});

it('uses default if length not set', () => {
Expand Down

0 comments on commit 50472b7

Please sign in to comment.