Function throttle

  • EN: Throttle

    ZH: 节流

    Usage:

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

    Parameters

    • func: T
    • wait: number
    • options: {
          leading?: boolean;
          trailing?: boolean;
      } = {}
      • Optional leading?: boolean
      • Optional trailing?: boolean

    Returns ThrottleFunc<T>