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 FrameworkJaxer Client Framework
1.01.0

Classes

Jaxer.Util.CRC32
Jaxer.Util.Certificate
Jaxer.Util.Certificate.CertInfo
Jaxer.Util.Cookie
Jaxer.Util.DOM
Jaxer.Util.DateTime
Jaxer.Util.Math
Jaxer.Util.MultiHash
Jaxer.Util.Stopwatch
Jaxer.Util.String
Jaxer.Util.Url
Jaxer.Util.Url.ParsedUrl

Functions

MethodActionJaxer Server FrameworkJaxer Client Framework
static getGlobalContext([Object obj]) : Object
Find the global context ('window', in the browser) to which the given object is ultimately parented. If no object is given, returns the developer page's window object, and if that does not exist for some reason, returns the framework's global context.

(Advanced)
Show Details1.0no

Parameters
Objectobj(optional)The object whose global context is to be found

Returns
ObjectThe global context ('window', in the browser)

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 Details1.0no

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

Returns
ObjectThe 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 Details1.01.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
ArrayThe 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 Details1.0no

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

Returns
ObjectThe extended clone.

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 intact, then use the native Array's filter method instead.
Show Details1.0no

Parameters
ArrayarrayThe source array to be filtered
FunctionfuncThe 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
ArrayReturns 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 findInGlobalContext(String objectName, [Object objForGlobalContext]) : Object
Finds the named object within the global context ('window', in the browser) to which the second argument is ultimately parented. If no second argument is given, finds the named object in the developer page's window object, and if that does not exist for some reason, finds it in the Jaxer framework's global context.
Show Details1.0no

Parameters
StringobjectNameThe name of the object to find. If this name contains periods (".") then it's split into subnames and each is used to search in the former. So "a.b.c" means get the value of the property "a" in the global context, and in it get the value of the property "b", and in it get the value of the property "c". If any of these is not defined it returns undefined.
ObjectobjForGlobalContext(optional)The object whose global context is the one to use for finding the named object, which defaults to the developer page's window object (or else the Jaxer framework's global)

Returns
ObjectThe found object, or undefined if it cannot be found

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

Parameters
ObjectobjectThe source object
Functionfilter(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.
BooleanasHash(optional)If true, returns the result as a hash (with all values set to true)

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

static hasProperties(Object object, String[] properties) : Boolean
Determine if the specified object contains all properties in a list of property names.
Show Details1.0no

Parameters
ObjectobjectThe source object
String[]propertiesThe list of property names to test on the specified object

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

static isArray(Object obj) : Boolean
Tests whether the given object is an Array object (even if it's from a different global context). This returns false on Array-like objects that are not in fact arrays, such as the arguments object inside a function.
Show Details1.0no

Parameters
ObjectobjThe object to test

Returns
BooleanTrue if it's an Array (or at least seems to be an Array), false otherwise

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

Parameters
ObjectobjThe object to test

Returns
BooleanTrue 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 Details1.0no

Parameters
ObjectobjThe object to test

Returns
Booleanfalse 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 Details1.0no

Parameters
FunctionfuncThe function to test

Returns
BooleanTrue 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 Details1.0no

Parameters
StringsourceThe source string to test

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

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 Details1.0no

Parameters
ArrayarrayThe source array
FunctionfuncThe 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
ArrayReturns 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 the signature of the native Array's map mathod.

static sleep(Number milliseconds) : void
Does nothing for the given number of milliseconds
Show Details1.0no

Parameters
NumbermillisecondsThe number of milliseconds to pause.

aptana_docs