mazey
    Preparing search index...

    Function debounce

    • Delay function execution until the specified time has passed since the last invocation.

      Usage:

      import { debounce } from "mazey";

      const foo = debounce(() => {
      console.log("The debounced function will only be invoked in 1000 milliseconds, the other invoking will disappear during the wait time.");
      }, 1000, true);

      Type Parameters

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

      Parameters

      • func: T

        Function to debounce.

      • wait: number

        Delay after the last invocation, in milliseconds.

      • Optionalimmediate: boolean

        Whether to invoke on the leading edge instead.

      Returns DebounceFunc<T>

      The debounced function.