Jaxer.Util : Object
Return to: Jaxer Framework index

A namespace to hold a miscellany of generic utility functions and other objects. In particular, it also holds sub-namespaces for more specific operations.

Platform Support

Jaxer Server Framework Jaxer Client Framework
1.0 1.0

Functions

Method Action Jaxer Server Framework Jaxer Client Framework
static clone(Object obj, [Boolean deep,] [Number maxDepth]) : Object
Clones an object (actually any argument) and returns the clone. If obj is of type "object", then the clone is created from the same constructor (but without any arguments). For a deep clone, every (enumerable) property is itself cloned; otherwise, every (enumerable) property is simply copied (by value or reference).
Show Details 1.0 no

Parameters
Object obj The object to clone. If it's not of type object, its value is simply copied and returned. It is not altered.
Boolean deep (optional)Whether to make a deep clone or a shallow one (just copy properties); by default, false.
Number maxDepth (optional)An optional maximum cloning depth. By default it's 10. This prevents infinite loops.

Returns
Object The new, cloned object.

static concatArrays([Object ...]) : Array
Returns an array whose elements consist of the elements of all the arrays or array-like objects passed in as arguments. If any of the arguments is null or undefined (i.e. is equivalent to false) it is skipped.
Show Details 1.0 1.0

Parameters
Object ... (optional)Any number of arrays or array-like objects (e.g. a function's arguments meta-array). Note that, unlike Array.concat, the arguments here need to be arrays or array-like objects that have a length property and an indexer (i.e. obj [ i ] is defined)

Returns
Array The concatenated array

static extend(Object obj, Object extensions) : Object
Extends an object by (shallow) cloning it and then copying all (enumerable) properties from the extensions object to the new cloned object.
Show Details 1.0 no

Parameters
Object obj The object to use as a base and extend. It is not altered.
Object extensions The object to use as extensions -- usually this is a simple hashmap of properties and their values.

Returns
Object The extended clone.

static filter(Array array, Function func) : Array
Remove items from an array that do not pass a given criteria. Each item in the specified array will be passed to the filtering function. If that function returns true, then the item will be appended to the resulting array. If the function returns false, the item is not added to the resulting array. Note that the specified array is not altered in place. A new array is created as a result of this function call.
Show Details 1.0 no

Parameters
Array array The source array to be filtered
Function func The filtering function to apply to each array item. This filter has two parameters. The first parameter is the current item in the array that is potentially being filtered. The second parameter is the index of the item potentially being filtered. The index can be used in cases where the filtering decision needs to be determined based on proximity to other items in the array

Returns
Array Returns a new array containing only items that were approved by the filtering function.

static filterInPlace(Array array, Function func) : Array
Remove items from an array that do not pass a given criteria. Each item in the specified array will be passed to the filtering function. If that function returns true, then the item will remain in the specified array. If the function returns false, the item is removed from the specified array. Note that the specified array is altered in place. If you prefer to create a new array, leaving the original in tact, then use Util.filter instead
Show Details 1.0 no

Parameters
Array array The source array to be filtered
Function func The filtering function to apply to each array item. This filter has two parameters. The first parameter is the current item in the array that is potentially being filtered. The second parameter is the index of the item potentially being filtered. The index can be used in cases where the filtering decision needs to be determined based on proximity to other items in the array

Returns
Array Returns the filtered array containing only items that were approved by the filtering function. Note that this instance will be the same as the instance passed into the function. This is provided as a convenience and to keep this function signature the same as Util.filter's signature.

static foreach(Array array, Function func) : void
Apply a function to each element in an array.
Show Details 1.0 no

Parameters
Array array The source array
Function func The function to apply to each of the items in the source array. The function has two parameters. The first parameter is the current item in the array to be process by this function. The second parameter is the index of the item being processed.

static getPropertyNames(Object object, [Function filter,] [Boolean asHash]) : Object
Get all property names or filtered subset of names from an object.
Show Details 1.0 no

Parameters
Object object The source object
Function filter (optional)An optional filter function to apply to the property's name and value. filter(name, value) should return something that's equivalent to true if the property is to be included.
Boolean asHash (optional)If true, returns the result as a hash (with all values set to true)

Returns
Object A list or hash of the property names depending on the value provided to the asHash parameter

static hasProperties(Object object, Array<String> properties) : Boolean
Determine if the specified object contains all properties in a list of property names.
Show Details 1.0 no

Parameters
Object object The source object
Array<String> properties The list of property names to test on the specified object

Returns
Boolean Returns true if all properties in the list exist on the specified object

static isDate(Object obj) : Boolean
Tests whether the given object is a Date object (even if it's from a different global context)
Show Details 1.0 no

Parameters
Object obj The object to test

Returns
Boolean True if it's a Date (or at least seems to be a Date), false otherwise

static isEmptyObject(Object obj) : Boolean
Tests whether the given object is devoid of any (enumerable) properties.
Show Details 1.0 no

Parameters
Object obj The object to test

Returns
Boolean false if there is (at least) one enumerable property, true otherwise

static isNativeFunction(Function func) : Boolean
Tests whether the given function is native (i.e. for which there is actually no source code)
Show Details 1.0 no

Parameters
Function func The function to test

Returns
Boolean True if it's a native function, false otherwise

static isNativeFunctionSource(String source) : Boolean
Tests whether the given string is the source of a native function (i.e. for which there is actually no source code)
Show Details 1.0 no

Parameters
String source The source string to test

Returns
Boolean True if it's a native function's source, false otherwise

static map(Array array, Function func) : Array
Create a new array by applying the result of a function to each of the items in the array.
Show Details 1.0 no

Parameters
Array array The source array
Function func The function to apply to each of the items in the source array. The function has two parameters. The first parameter is the current item in the array that is being transformed. The second parameter is the index of the item being transformed.

Returns
Array Returns a new array where each item is the result of the specified function as it was applied to each of the source array items.

static mapInPlace(Array array, Function func) : Array
Replace each item of an array by applying a function and then replacing the original item with the results of that function.
Show Details 1.0 no

Parameters
Array array The source array
Function func The function to apply to each of the items in the source array. The function has two parameters. The first parameter is the current item in the array that is being transformed. The second parameter is the index of the item being transformed.

Returns
Array Returns the mapped array. Note that this instance will be the same as the instance passed into the function. This is provided as a convenience and to keep this function's signature the same as Util.map's signature.

static sleep(Number milliseconds) : void
Does nothing for the given number of milliseconds
Show Details 1.0 no

Parameters
Number milliseconds The number of milliseconds to pause.

aptana_docs