Skip to content

Commit

Permalink
Make CLEAR_THRESHOLD_MS a class field
Browse files Browse the repository at this point in the history
  • Loading branch information
mrlika committed Jan 10, 2024
1 parent bafc1f5 commit d1ff740
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions packages/p2p-media-loader-core/src/bandwidth-calculator.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
const CLEAR_THRESHOLD_MS = 10000;

export class BandwidthCalculator {
private simultaneousLoadingsCount = 0;
private readonly bytes: number[] = [];
Expand All @@ -8,6 +6,8 @@ export class BandwidthCalculator {
private noLoadingsTotalTime = 0;
private allLoadingsStoppedTimestamp = 0;

constructor(private readonly clearThresholdMs = 10000) {}

addBytes(bytesLength: number, now = performance.now()) {
this.bytes.push(bytesLength);
this.shiftedTimestamps.push(now - this.noLoadingsTotalTime);
Expand Down Expand Up @@ -82,7 +82,7 @@ export class BandwidthCalculator {
if (!this.shiftedTimestamps.length) return;
const threshold =
this.shiftedTimestamps[this.shiftedTimestamps.length - 1] -
CLEAR_THRESHOLD_MS;
this.clearThresholdMs;

let samplesToRemove = 0;
for (const timestamp of this.shiftedTimestamps) {
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d1ff740

Please sign in to comment.