utils.function
namespace function
a collection of utility functions
Summary
Public Methods
defer(func: Function, thisArg: object, args: unknown) → {number}
Executes a function as soon as the interpreter is idle (stack empty).
// execute myFunc() when the stack is empty,
// with the current context and [1, 2, 3] as parameter
me.utils.function.defer(myFunc, this, 1, 2, 3);
Name | Type | Description |
---|---|---|
func | Function |
The function to be deferred. |
thisArg | object |
The value to be passed as the this parameter to the target function when the deferred function is called |
args | unknown |
Optional additional arguments to carry for the function. |
Type | Description |
---|---|
number |
id that can be used to clear the deferred function using clearTimeout |
throttle(fn: Function, delay: number, no_trailing: no_trailing) → {Function}
returns a function that, when invoked will only be triggered at most once during a given window of time
Name | Type | Description |
---|---|---|
fn | Function |
the function to be throttled. |
delay | number |
The delay in ms |
no_trailing | no_trailing |
disable the execution on the trailing edge |
Type | Description |
---|---|
Function |
the function that will be throttled |