lodash.debounce
Creates a debounced function that delays invoking
func
until afterwait
milliseconds have elapsed since the last time the debounced function was invoked. The debounced function comes with acancel
method to cancel delayedfunc
invocations and aflush
method to immediately invoke them. 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 debounced function. Subsequent calls to the debounced function return the result of the lastfunc
invocation.
从防抖函数最后一次被调用起,开始计时,经过延迟参数规定的时间后,原函数将被调用。
lodash.throttle
Creates a throttled function that only invokes
func
at most once per everywait
milliseconds. The throttled function comes with acancel
method to cancel delayedfunc
invocations and aflush
method to immediately invoke them. 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.
创建一个节流函数,使得原函数在等待时间内,最多被调用一次。