(options = {})
| 433 | |
| 434 | class AdaptivePoller { |
| 435 | constructor(options = {}) { |
| 436 | const base = Number(options.baseIntervalMs ?? options.baseMs ?? 1200); |
| 437 | const max = Number(options.maxIntervalMs ?? options.maxMs ?? 12000); |
| 438 | this.baseIntervalMs = Math.max(300, Number.isFinite(base) ? base : 1200); |
| 439 | this.maxIntervalMs = Math.max(this.baseIntervalMs, Number.isFinite(max) ? max : 12000); |
| 440 | this.minIntervalMs = Math.max(250, Math.min(this.baseIntervalMs, Number(options.minIntervalMs || this.baseIntervalMs))); |
| 441 | this.jitterRatio = Math.min(0.2, Math.max(0, Number(options.jitterRatio || 0.08))); |
| 442 | this.failureCount = 0; |
| 443 | this.successCount = 0; |
| 444 | this.lastDelayMs = this.baseIntervalMs; |
| 445 | } |
| 446 | |
| 447 | getConnectionMultiplier() { |
| 448 | const connection = navigator?.connection || navigator?.mozConnection || navigator?.webkitConnection; |
nothing calls this directly
no outgoing calls
no test coverage detected