jbooze.js


file jbooze.js
Example for jBoozeDoc tool.
If you are interested in jBooze library, see jbooze.com
Authors:
den
Version:
0.55

Class Summary
Base class for jbooze exceptions

Structure Summary
Structure containing jBooze configuration.

Variable Summary
public static string $break
Special exception that is used to break iterators
function()[] _closeHooks
array of functions that should be called on app shutdown
object _global
Contains reference to global namespace
string _startupFile
default name of startup file.

Function Summary
public static int add(int first, [int second])
Adds two numbers together.
addUnloadHook(function() func)
Adds a shutdown hook - a function that should be called at app shutdown
forEach(array arr, iteratorCallback func, boolean backwards)
forEach(object obj, iteratorCallback func)
Execute a function for each element of array or member of structure
isEmpty(object obj)
Checks if the structure is empty, i.e.
notImplemented(string methodName)
Used to indicate that method is not implemented/abstract by throwing Exception
int search(array arr, object item, function (item, arrayItem) comparator)
Searches for item in array
array toArray(object data)
Converts argument to array, if possible.

Function Interface Summary
iteratorCallback(item, int index)
iteratorCallback(key, value)
callback for iterators

Variable Details

variable public static string $break

Special exception that is used to break iterators
Defined in jbooze.js

variable function()[] _closeHooks

array of functions that should be called on app shutdown
Defined in jbooze.js

variable object _global

Contains reference to global namespace
Defined in jbooze.js

variable string _startupFile

default name of startup file. comment for this member is an example of usage of var alias
Defined in jbooze.js

Function Details

function add

public static int add(int first, [int second])
Adds two numbers together. Sample only. Could be used as mixin to SomeClass
Parameters:
first - first number
[second] - second number
Returns:
sum of two numbers
Throws:
InvalidArgumentException when shit happens
Authors:
den
Version:
0.55
Since:
0.9
Defined in jbooze.js

function addUnloadHook

addUnloadHook(function() func)
Adds a shutdown hook - a function that should be called at app shutdown
Parameters:
func - hook that should be called at shutdown
Defined in jbooze.js

function forEach

forEach(array arr, iteratorCallback func, boolean backwards)
forEach(object obj, iteratorCallback func)
Execute a function for each element of array or member of structure
Parameters:
Syntax 1 - array based (iteration over array elements)
arr - array to be iterated
func - function to be called for each array element.
backwards - if iteration should start from the end of the array. This is optional parameter, default value is "false". Iteration from the end of the array could be useful when iterator function removes elements from the array
Syntax 2 - object based (iteration over object properties)
obj - source object
func - function to be called for each object property.
See also:
Version:
0.55
Since:
0.1
Defined in jbooze.js

function isEmpty

isEmpty(object obj)
Checks if the structure is empty, i.e. does not have any members
Parameters:
obj structure
Returns:
true if structure has at least one member
Defined in jbooze.js

function notImplemented

notImplemented(string methodName)
Used to indicate that method is not implemented/abstract by throwing Exception
Parameters:
methodName name of the method that is not implemented
Defined in jbooze.js

function search

int search(array arr, object item, function (item, arrayItem) comparator)
Searches for item in array
Parameters:
arr - array containing data
item - item that is being searched for
comparator (optional) - if specified, then returns -1 when item < arrayItem; returns 0 if item == arrayItem; returns 1 otherwise
Returns:
the index where item was found or -1 otherwise
Defined in jbooze.js

function toArray

array toArray(object data)
Converts argument to array, if possible. If data is array, then copy of data is returned. If data has method toArray then the result of that method is returned. If data has property length, then it is assumed that it is possible to iterate over elements of data as if over array. If neither of these conditions are met, then empty array is returned.
Parameters:
data - object that should be converted to array
Returns:
result of conversion to array
Defined in jbooze.js

Function Interface Details

ifunction iteratorCallback

iteratorCallback(item, int index)
iteratorCallback(key, value)
callback for iterators
Parameters:
Syntax 1 - iterating over arrays or collections
item - current item in array/collection/etc
index - index of item in array/collection/etc
Syntax 2 - iterating over maps
key - value in the map
value - key of the value
Defined in jbooze.js