The function to be throttled.
Rest
...args: AThe number of milliseconds to throttle invocations to.
Optional
options: { Options object.
Optional
leading?: booleanIf true
the func
will be executed on the leading edge of the timeout.
true
Optional
trailing?: booleanIf true
the func
will be executed on the trailing edge of the timeout.
true
Rest
...args: Aconst throttled = throttle(() => console.log('throttled'), 100)
throttled() // will be called immediately
throttled() // will be ignored
await delay(100)
throttled() // will be called after 100ms
Creates a throttled function that will execute
func
at most once pertimeInMs
interval.