Luxar Viewer API Documentation - v2026.10.19
    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 both record() and rate() advance a start index past expired entries (O(1) amortized), and only when the dead prefix exceeds half the buffer does record() slice it off in one allocation. Expiring on record() too is what bounds the buffer: rate() is read only while the monitor is visible.

    Index
    windowMs: number
    window: { timestamp: number; bytes: number }[] = []
    start: number = 0
    • Record a network transfer of bytes at the current time. Expires aged-out entries, then 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