Luxar Viewer API Documentation - v2026.9.22
    Preparing search index...

    Sliding-window bandwidth tracker.

    Records timestamped byte counts on record(bytes) and returns the average bytes/sec over the trailing windowMs on rate().

    Implementation note (R5 — load-bearing): Naive pruning via Array.shift() is O(n) per pop and degrades to O(n²) under sustained high fetch rates. Instead we advance a start index past expired entries (O(1) amortized in rate()), and only when the dead prefix exceeds half the buffer do we slice it off in one allocation (record() path). This keeps push amortized O(1) without letting the buffer grow unbounded.

    Index
    windowMs: number
    window: { timestamp: number; bytes: number }[] = []
    start: number = 0
    • Record a network transfer of bytes at the current time. Runs the R5 amortized compaction: if the dead prefix is larger than the live tail, slice it off in one O(n) hit.

      Parameters

      • bytes: number

      Returns void