Package
caplin.core

Utility

A utility class that provides miscellaneous functionality.

Constructor Summary

Attributes Name and Description
caplin.core.Utility()

This is a static utility class and does not need to be instantiated.

Method Summary

Attributes Name and Description
<static> Function debounce(Function func, Numeric wait, Boolean immediate)

Returns a function, that, as long as it continues to be invoked, will not be triggered.

<static> Function throttle(Function func, Numeric wait, Map options)

Returns a function, that, when invoked, will only be triggered at most once during a given window of time.

Constructor Detail

caplin.core.Utility()

This is a static utility class and does not need to be instantiated.

Method Detail

<static> Function debounce(Function func, Numeric wait, Boolean immediate)

Returns a function, that, as long as it continues to be invoked, will not be triggered. The function will be called after it stops being called for wait milliseconds. If immediate is passed, trigger the function on the leading edge, instead of the trailing.

Parameters
Function func The function to debounce
Numeric wait The wait window time in milliseconds
Boolean immediate Trigger the function on the leading edge
Returns
{Function} A debounced function

<static> Function throttle(Function func, Numeric wait, Map options)

Returns a function, that, when invoked, will only be triggered at most once during a given window of time. Normally, the throttled function will run as much as it can, without ever going more than once per wait duration. If you would like to disable the execution on the leading edge, pass {leading: false} as the options parameter. To disable execution on the trailing edge, pass {trailing: false} as the options parameter.

This function comes from Underscore.js and is the same exact implementation.

Parameters
Function func The function to throttle.
Numeric wait The wait window time in milliseconds.
Map options A map of options.
Returns
{Function} A throttled function.