ixfx
    Preparing search index...

    Class RateTracker

    Tracks the rate of events. It's also able to compute the min,max and average interval between events.

    const clicks = Trackers.rate();

    // Mark when a click happens
    document.addEventListener(`click`, () => clicks.mark());

    // Get details
    clicks.perSecond; // How many clicks per second
    clicks.perMinute; // How many clicks per minute

    timeoutInterval is a useful option to make the tracker reset after some period without mark() being called.

    Another useful option is sampleLimit, which sets an upper bound for how many events to track. A smaller value means the results will more accurately track, but it might be less smooth.

    // Eg reset tracker after 5 seconds of inactivity
    const clicks = Trackers.rate({
    sampleLimit: 10,
    timeoutInterval: { secs: 5 }
    });
    Index

    Accessors

    • get elapsed(): number

      Returns the time period (in milliseconds) that encompasses the data set. Eg, a result of 1000 means there's data that covers a one second period.

      Returns number

    Constructors

    Methods

    • Compute {min,max,avg} for the interval between events.

      Returns { avg: number; max: number; min: number }