Function debounce

  • EN: Debounce, used to delay the execution of a function until a specified time has passed since the last invocation.

    ZH: 防抖,用于在最后一次调用后的指定时间内延迟函数的执行。

    Usage:

    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) => any)

    Parameters

    • func: T
    • wait: number
    • Optional immediate: boolean

    Returns DebounceFunc<T>