Takaro - v0.4.11
    Preparing search index...

    Function throttle

    • Creates a throttled function that only invokes func at most once per every wait milliseconds. The throttled function comes with a cancel method to cancel delayed invocations and a flush method to immediately invoke them. Provide an options object to indicate that func should be invoked on the leading and/or trailing edge of the wait timeout. Subsequent calls to the throttled function return the result of the last func call.

      Note: If leading and trailing options are true, func is invoked on the trailing edge of the timeout only if the the throttled function is invoked more than once during the wait timeout.

      Type Parameters

      • T extends (...args: any) => any

      Parameters

      • func: T

        The function to throttle.

      • Optionalwait: number

        The number of milliseconds to throttle invocations to.

      • Optionaloptions: ThrottleSettingsLeading

        The options object.

        • leading

          Specify invoking on the leading edge of the timeout.

        • trailing

          Specify invoking on the trailing edge of the timeout.

      Returns DebouncedFuncLeading<T>

      Returns the new throttled function.

    • Type Parameters

      • T extends (...args: any) => any

      Parameters

      Returns DebouncedFunc<T>