mazey
    Preparing search index...

    Function throttle

    • Limit how frequently a function can be invoked over time.

      Usage:

      import { throttle } from "mazey";

      const foo = throttle(() => {
      console.log("The function will be invoked at most once per every wait 1000 milliseconds.");
      }, 1000, { leading: true });

      Reference: Lodash

      Type Parameters

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

      Parameters

      • func: T

        Function to throttle.

      • wait: number

        Minimum interval between invocations, in milliseconds.

      • options: { leading?: boolean; trailing?: boolean } = {}
        • Optionalleading?: boolean

          Whether to invoke on the leading edge.

        • Optionaltrailing?: boolean

          Whether to invoke on the trailing edge.

      Returns ThrottleFunc<T>

      The throttled function.