Class Throttler<T, U, V>

Wraps and throttles a function that can be called multiple times and only executes the underlying function once per interval.

Typeparam

T - The resolved type of the underlying function. Defaults to any.

Typeparam

U - The rejected type of the underlying function. Defaults to any.

Typeparam

V - Arguments for the underlying function. Defaults to any[].

Type Parameters

  • T = any

  • U = any

  • V extends any[] = any[]

Hierarchy

Constructors

Properties

Accessors

Methods

Constructors

  • Instantiate a throttler.

    Type Parameters

    • T = any

    • U = any

    • V extends any[] = any[]

    Parameters

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

      The function being throttled.

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

          • Rest ...args: V

          Returns T | Promise<T>

    • Optional options: number | Throttler.IOptions

      Throttling configuration or throttling limit in ms.

      Notes

      The edge defaults to leading; the limit defaults to 500.

    Returns Throttler<T, U, V>

Properties

_interval: number
_trailing: boolean = false
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