Module

base/utils/func

Function module.

View Source utils/fn.js, line 1

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 N milliseconds. If `immediate` is passed, trigger the function on the leading edge, instead of the trailing. The function also has a property 'clear' that is a function which will clear the timer to prevent previously scheduled executions.
Parameters:
Name Type Description
func function Function to wrap.
wait Number Timeout in ms (`60`).
immediate Boolean Whether to execute at the beginning (`false`).
See:

View Source utils/fn.js, line 25

A new function that wraps the `func` function passed in.
function

static noop() → {undefined}

Returns undefined irrespective of the arguments passed to it. Using the noop the intent of a default callback is clear. An empty function might indicate unfinished business.

View Source utils/fn.js, line 108

undefined

static once(fn, context) → {function}

Execute functionality just once.
Parameters:
Name Type Description
fn function Function to execute just once.
context * Context to execute the function in.

View Source utils/fn.js, line 118

function

static throttle(func, wait) → {function}

Returns a new function that, when invoked, invokes `func` at most once per `wait` milliseconds.
Parameters:
Name Type Description
func function Function to wrap.
wait Number Number of milliseconds that must elapse between `func` invocations.

View Source utils/fn.js, line 77

A new function that wraps the `func` function passed in.
function