Caplin Trader 4.8.0

Class: module:caplin/core/Utility

module:caplin/core/Utility

Constructor

new module:caplin/core/Utility()

A utility class that provides miscellaneous functionality.

Methods

(static) debounce(func, wait, immediate) → {function}

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:
Name Type Description
func function The function to debounce
wait Numeric The wait window time in milliseconds
immediate Boolean Trigger the function on the leading edge
Returns:
A debounced function
Type
function

(static) throttle(func, wait, options) → {function}

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:
Name Type Description
func function The function to throttle.
wait Numeric The wait window time in milliseconds.
options Map A map of options.
Returns:
A throttled function.
Type
function