core/utils

Description:
  • Utility functions.

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

Utility functions.

Members

(static, constant) getNormalisedComponent

Description:
  • Normalise the provided component such that '', 'moodle', and 'core' are treated consistently.

Source:

Normalise the provided component such that '', 'moodle', and 'core' are treated consistently.

(static, constant) wrapPromiseInWhenable

Description:
  • Wrap a Native Promise in a jQuery Whenable for b/c.

Source:

Wrap a Native Promise in a jQuery Whenable for b/c.

(inner, constant) debounceMap

Source:
Properties:
Name Type Description
debounceMap Map

A map of functions to their debounced pending promises.

Methods

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

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

Source:
Parameters:
Name Type Attributes Description
func function

The function to debounce

wait Number

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

options Object <optional>
Properties
Name Type Attributes Default Description
pending boolean <optional>
false

Whether to wrap the debounced method in a pending promise

cancel boolean <optional>
false

Whether to add a cancel method to the debounced function

Returns:
Type
function

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

Description:
  • 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.

Source:
Parameters:
Name Type Description
func function

The function to throttle

wait Number

The number of milliseconds to wait between executions

Returns:
Type
function