Skip to main content

CommonLimitFunction

Callable

  • CommonLimitFunction<FunctionType>(func: FunctionType, minWait?: number, maxWait?: number): FunctionType

  • 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

    • FunctionType: (...args: any) => any

    Parameters

    • func: FunctionType

      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 FunctionType

    • A debounced or throttled version of the function