The function to throttle
The number of milliseconds to throttle invocations to
Optional
options:
{ The options object
Optional
leading?: boolean
Specify invoking on the leading edge of the timeout
Optional
trailing?: boolean
Specify invoking on the trailing edge of the timeout
Returns the new throttled function
Generated using TypeDoc
Creates a throttled function that only invokes
func
at most once per everywait
milliseconds (or once per browser frame). Provideoptions
to indicate whetherfunc
should be invoked on the leading and/or trailing edge of thewait
timeout. Thefunc
is invoked with the last arguments provided to the throttled function. Subsequent calls to the throttled function return the result of the lastfunc
invocation. Note: Ifleading
andtrailing
options aretrue
,func
is invoked on the trailing edge of the timeout only if the throttled function is invoked more than once during thewait
timeout. Ifwait
is0
andleading
isfalse
,func
invocation is deferred until the next tick, similar tosetTimeout
with a timeout of0
.