Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • default

Index

Constructors

Accessors

Methods

Constructors

constructor

  • new default(interval?: number, maxCount?: number, count?: number, started?: number): default
  • Parameters

    • interval: number = RATE_LIMITER_INTERVAL_MS
    • maxCount: number = MAX_PINGS_PER_INTERVAL
    • count: number = 0
    • Optional started: number

    Returns default

Accessors

elapsed

  • get elapsed(): number

Methods

getState

  • Tries to increment the internal counter.

    Returns { remainingTime?: number; state: RateLimiterState }

    The current state of the RateLimiter plus the remaining time (in milliseconds) until the end of the current window.

Private reset

  • reset(): void

Private shouldReset

  • shouldReset(): boolean
  • The rate limiter should reset if

    1. It has never started i.e. started is still undefined;
    2. It has been started more than the interval time ago;
    3. Something goes wrong while trying to calculate the elapsed time since the last reset.

    Returns boolean

    Whether or not this rate limiter should reset.

Generated using TypeDoc