Creates a throttled version of a function that ensures it is not called more than once within the specified time interval.
The function to throttle.
The time interval, in millisecond, during which subsequent calls are ignored.
A throttled function that invokes func at most once per preventTime interval.
func
preventTime
let count = 1const myfunc = () => { console.log('Call ' + count) count++}const myfuncThrottle = PUtilsFunction.throttle(myfunc, 1000)myfuncThrottle() // Executes: 'Call 1'myfuncThrottle() // Ignored: called to soon. Copy
let count = 1const myfunc = () => { console.log('Call ' + count) count++}const myfuncThrottle = PUtilsFunction.throttle(myfunc, 1000)myfuncThrottle() // Executes: 'Call 1'myfuncThrottle() // Ignored: called to soon.
Creates a throttled version of a function that ensures it is not called more than once within the specified time interval.