Creates a debounced function that delays invoking
func until after
milliseconds have elapsed since the last time the debounced function was
invoked, or until the next browser frame is drawn. The debounced function
comes with a
cancel method to cancel delayed
func invocations and a
flush method to immediately invoke them. Provide
options to indicate
func should be invoked on the leading and/or trailing edge of the
wait timeout. The
func is invoked with the last arguments provided to the
debounced function. Subsequent calls to the debounced function return the
result of the last
trailing options are
invoked on the trailing edge of the timeout only if the debounced function
is invoked more than once during the
func invocation is deferred
until the next tick, similar to
setTimeout with a timeout of
wait is omitted in an environment with
invocation will be deferred until the next frame is drawn (typically about
See David Corbacho's article
for details over the differences between
The function to debounce.
The number of milliseconds to delay; if omitted,
requestAnimationFrame is used (if available).
The options object.
Returns the new debounced function.