pols-utils - v5.3.11
    Preparing search index...

    Function throttle

    • Creates a throttled version of a function that ensures it is not called more than once within the specified time interval.

      Parameters

      • func: (...args: any[]) => any

        The function to throttle.

      • preventTime: number

        The time interval, in millisecond, during which subsequent calls are ignored.

      Returns (...args: unknown[]) => any

      A throttled function that invokes func at most once per preventTime interval.

      let count = 1
      const myfunc = () => {
      console.log('Call ' + count)
      count++
      }
      const myfuncThrottle = PUtilsFunction.throttle(myfunc, 1000)

      myfuncThrottle() // Executes: 'Call 1'
      myfuncThrottle() // Ignored: called to soon.