Class implementing a time-based rate limiter. Allows requests based on specified timeframes and their respective limits.

Implements

Constructors

Properties

Methods

Constructors

Properties

limits: number[] = []
queues: DecayCache<Dequeue<number>[]>
timeframes: number[] = []

Methods

  • Makes a request within the rate limiter. Checks if the request is allowed based on the timeframes and their limits.

    Parameters

    • key: string

    Returns boolean

    True if the request is allowed, otherwise false.

  • Private

    Initializes the request queues for a specific key. Each key will have multiple queues, each corresponding to a specific timeframe and its limit.

    Returns Dequeue<number>[]

    An array of deques representing the request queues for the key.

Generated using TypeDoc