Class RateLimiter<T, U, V>Abstract

A base class to implement rate limiters with different invocation strategies.

Typeparam

T - The resolved type of the underlying function.

Typeparam

U - The rejected type of the underlying function.

Typeparam

V - Arguments for the underlying function.

Type Parameters

  • T

  • U

  • V extends any[]

Hierarchy

Implements

Constructors

Properties

Accessors

Methods

Constructors

  • Instantiate a rate limiter.

    Type Parameters

    • T

    • U

    • V extends any[]

    Parameters

    • fn: ((...args) => T | Promise<T>)

      The function to rate limit.

        • (...args): T | Promise<T>
        • Parameters

          • Rest ...args: V

          Returns T | Promise<T>

    • limit: number = 500

      The rate limit; defaults to 500ms.

    Returns RateLimiter<T, U, V>

Properties

args: undefined | V = undefined

Arguments for the underlying function.

limit: number

The rate limit in milliseconds.

payload: null | PromiseDelegate<T> = null

A promise that resolves on each successful invocation.

poll: Poll<T, U, "invoked">

The underlying poll instance used by the rate limiter.

Accessors

Methods

Generated using TypeDoc