Skip to main content

CommonLimitFunction

Callable

  • CommonLimitFunction<argsT, retT>(func: (...args: argsT) => retT, minWait?: number, maxWait?: number): (...args: argsT) => retT

  • Creates a wrapper for a function to limit how often it can be called. The player-defined wait interval setting determines the allowed frequency. Below 100 ms the function will be throttled and above will be debounced.


    Type parameters

    • argsT: any[]
    • retT

    Parameters

    • func: (...args: argsT) => retT

      The function to limit calls of

      • optionalminWait: number = 0

        A lower bound for how long the wait interval can be, 0 by default

      • optionalmaxWait: number = 1000

        An upper bound for how long the wait interval can be, 1 second by default

      Returns (...args: argsT) => retT

      • A debounced or throttled version of the function
        • (...args: argsT): retT
        • Parameters

          • rest...args: argsT

          Returns retT