fn.js
Methods
-
staticmodule:fn.debounce(func, wait, immediate, context){function}
-
Creates a debounced function that delays invoking
funcuntil afterwaitmilliseconds have elapsed since the last time the debounced function was invoked.Inspired by lodash and underscore implementations.
Name Type Default Description funcfunction The function to wrap with debounce behavior.
waitnumber The number of milliseconds to wait after the last invocation.
immediateboolean optional Whether or not to invoke the function immediately upon creation.
contextObject window optional The "context" in which the debounced function should debounce. For example, if this function should be tied to a Video.js player, the player can be passed here. Alternatively, defaults to the global
windowobject.Returns:
Type Description function A debounced function. -
staticmodule:fn.throttle(fn, wait){function}
-
Wraps the given function,
fn, with a new function that only invokesfnat most once per everywaitmilliseconds.Name Type Description fnfunction The function to be throttled.
waitnumber The number of milliseconds by which to throttle.
Returns:
Type Description function