core/utils

Utility functions.

Source:
License:
  • http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Methods

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

Source:

Create a wrapper function to debounce the execution of the given function. Each attempt to execute the function will reset the cooldown period.

Parameters:
Name Type Description
func function

The function to debounce

wait Number

The number of milliseconds to wait after the final attempt to execute

Returns:
Type
function

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

Source:

Create a wrapper function to throttle the execution of the given

function to at most once every specified period.

If the function is attempted to be executed while it's in cooldown (during the wait period) then it'll immediately execute again as soon as the cooldown is over.

Parameters:
Name Type Description
func function

The function to throttle

wait Number

The number of milliseconds to wait between executions

Returns:
Type
function