zibri
    Preparing search index...

    A rate limiter that provides an "isAvailable" method which ensures that no more than the provided maximum can be used.

    Index

    Methods

    • Checks whether or not the provided count of the limited resource is currently available or if it has been used up.

      Parameters

      • count: number

        The amount of the limited resource to request.

      Returns boolean

      True when the provided count is available, false otherwise.

    • Creates a rate limiter with a custom interval.

      Parameters

      • max: number

        The maximum available per the given interval.

      • intervalInMs: number

        The interval in ms.

      • initialTokens: number = max

        The amount of initial tokens to fill. Defaults to the value of max.

      Returns RateLimiter

      The RateLimiter.

    • Creates a rate limiter with the provided maximum available per day.

      Parameters

      • max: number

        The maximum available per day.

      • initialTokens: number = max

        The amount of initial tokens to fill. Defaults to the value of max.

      Returns RateLimiter

      The RateLimiter.

    • Creates a rate limiter with the provided maximum available per hour.

      Parameters

      • max: number

        The maximum available per hour.

      • initialTokens: number = max

        The amount of initial tokens to fill. Defaults to the value of max.

      Returns RateLimiter

      The RateLimiter.

    • Creates a rate limiter with the provided maximum available per minute.

      Parameters

      • max: number

        The maximum available per minute.

      • initialTokens: number = max

        The amount of initial tokens to fill. Defaults to the value of max.

      Returns RateLimiter

      The RateLimiter.

    • Creates a rate limiter with the provided maximum available per second.

      Parameters

      • max: number

        The maximum available per seconds.

      • initialTokens: number = max

        The amount of initial tokens to fill. Defaults to the value of max.

      Returns RateLimiter

      The RateLimiter.