OpenTV Player Web HTML5

Module: fn

fn

fn.js

Methods

staticmodule:fn.bind(context, fn, uid){function}

Bind (a.k.a proxy or context). A simple method for changing the context of a function.

It also stores a unique id on the function so it can be easily removed from events.

Name Type Description
context Mixed

The object to bind as scope.

fn function

The function to be bound to a scope.

uid number optional

An optional unique ID for the function to be set

Returns:
Type Description
function The new function that will be bound into the context given

staticmodule:fn.debounce(func, wait, immediate, context){function}

Creates a debounced function that delays invoking func until after wait milliseconds have elapsed since the last time the debounced function was invoked.

Inspired by lodash and underscore implementations.

Name Type Default Description
func function

The function to wrap with debounce behavior.

wait number

The number of milliseconds to wait after the last invocation.

immediate boolean optional

Whether or not to invoke the function immediately upon creation.

context Object window optional

The "context" in which the debounced function should debounce. For example, if this function should be tied to a Video.js player, the player can be passed here. Alternatively, defaults to the global window object.

Returns:
Type Description
function A debounced function.

staticmodule:fn.throttle(fn, wait){function}

Wraps the given function, fn, with a new function that only invokes fn at most once per every wait milliseconds.

Name Type Description
fn function

The function to be throttled.

wait number

The number of milliseconds by which to throttle.

Returns:
Type Description
function