Module: Utils

Collection of utility functions
Source:

Methods

(inner) _else(else_clause) → {Deferred}

Parameters:
Name Type Description
else_clause function
Source:
Returns:
Type
Deferred

(inner) _if(condition) → {IfThenElse}

ASYNC Builds an object chainable with these methods: .then().else().run() and eventually you can call .then() after run()
Parameters:
Name Type Description
condition boolean
Source:
Returns:
{_if: function, _then:function, _else:function,run:function }
Type
IfThenElse

(inner) _then(then_clause) → {IfThenElse}

Parameters:
Name Type Description
then_clause function
Source:
Returns:
Type
IfThenElse

(inner) asDeferred(expression) → {Deferred}

ASYNC Evaluates the expression. if it is a deferred function then returns it, otherwise returns a Deferred
Parameters:
Name Type Description
expression function
Source:
Returns:
Type
Deferred

(inner) callOptAsync(fn) → {Deferred}

ASYNC Calls a function fn that may have a callback parameter and returns a deferred value that will receive the result of fn If fn has the parameter it is considered a callback that will receive the optional result as first parameter If fn has no parameter it is considered a sincronous function its result is used to fullfill the deferred. If fn returns a deferred, its inner result is used to fullfill the result The averall result is always a deferred value
Parameters:
Name Type Description
fn function
Source:
Returns:
Type
Deferred

(inner) fConst(k)

SYNC Returns a constant function
Parameters:
Name Type Description
k type
Source:

(inner) filterArrayOnField(arr, field) → {Array.<object>}

SYNC Returns the array of field value, taken from an object array, where field is not null or undefined
Parameters:
Name Type Description
arr Array.<object>
field string
Source:
Returns:
Type
Array.<object>

(inner) optBind(fun, obj, args) → {function}

SYNC Returns function "fun" binded to "obj" or null if fun is null. Arguments can be provided
Parameters:
Name Type Description
fun function function to bind
obj object object to use as "this"
args object optional arguments
Source:
Returns:
Type
function

(inner) optionalDeferred(condition, func, defaultValue) → {Deferred}

ASYNC Optionally executes a Deferred function, otherwise returns a deferred resolved with defaultValue
Parameters:
Name Type Description
condition boolean
func function
defaultValue object
Source:
Returns:
Type
Deferred

(inner) run() → {Deferred}

Source:
Returns:
Type
Deferred

(inner) sequence(thisObject, funArgs) → {function}

SYNC This works like a $.When with optional async functions
Parameters:
Name Type Description
thisObject object
funArgs Array.<object>
Source:
Returns:
Type
function

(inner) skipRun(func) → {Deferred}

ASYNC returns deferred function that accepts a parameter
Parameters:
Name Type Description
func function
Source:
Returns:
Type
Deferred

(inner) thenSequence() → {Deferred}

ASYNC Builds a chained function, chaining each the Deferred function with "then"
Parameters:
Name Type Description
allDeferred.It Array.<function()> is an array of function that must be return a deferred
Source:
Returns:
Type
Deferred