This namespace includes some utility functions available to the user.
Members
(static) INVALID_VALUE
This value can be assigned to a data table to signify that data is not valid.
Any other member depending on this value will withhold the calcalation and also
return this invalid value.
(static) MEMBER_FUNCTION_INVALID_THROWABLE
This is a special throwable that is used to exit a function when the function definition depends
on another invalid value. I don't like to use exceptions for non-exceptional cases, which
I consider this to be, but I couldn't figure out how else to exit the function.
(static) MEMBER_FUNCTION_PENDING_THROWABLE
This is a special throwable that is used to exit a function when the function definition depends
on another pending value. I don't like to use exceptions for non-exceptional cases, which
I consider this to be, but I couldn't figure out how else to exit the function.
(static) STATE_ERROR
Error State - used by members
(static) STATE_INVALID
Invalid State - used by members
(static) STATE_NORMAL
None State - used by members. This indicates no state information is present.
(static) STATE_NORMAL
Normal State - used by members
(static) STATE_PENDING
Pending State - used by members
Methods
(static) callbackRequest(url, onSuccess, onError, options)
This method does a standard callback request. It includes the following options:
- "method" - HTTP method, default value is "GET"
- "body" - HTTP body for the request
- "header" - HTTP headers, example: {"Content-Type":"text/plain","other-header":"xxx"}
Parameters:
Name | Type | Description |
---|---|---|
url |
String | This is the url to be requested |
onSuccess |
function | This is a callback that will be called if the request succeeds. It should take a String request body argument. |
onError |
function | This is the callback that will be called it the request fails. It should take a String error message argument. |
options |
Object | These are options for the request. |
(static) deepFreeze()
This method takes a field which can be an object,
array or other value. If it is an object or array it
freezes that object and all of its children, recursively.
Warning - this does not check for cycles (which are not in JSON
objects but can be in javascript objects)
Implementation from Mozilla
(static) formatString(format, stringArgs) → {String}
This method does format string functionality. Text should include
{i} to insert the ith string argument passed.
Parameters:
Name | Type | Description |
---|---|---|
format |
String | This is a format string to format the output. |
stringArgs |
Array | These are the values which should be placed into the format string. |
Returns:
The format string with the proper inserted values is returned.
- Type
- String
(static) getNormalizedCopy(json1) → {Boolean}
This method returns a copied json that has the order in all JSON objects/"maps" normalized to alphabetical.
The order of JSON arrays is NOT modified.
This is intended for the purpose of comparing json objects.
Parameters:
Name | Type | Description |
---|---|---|
json1 |
JSON | This is a JSON valued object |
Returns:
- Returns whether or not the objects are equal
- Type
- Boolean
(static) getObjectType(object) → {String}
This method returns the object type. The Allowed types are:
String, Number, Boolean, Date, Object, Array, Function, null, undefined.
Parameters:
Name | Type | Description |
---|---|---|
object |
Object | This is the object for which the type is desired. |
Returns:
This is the type for the object.
- Type
- String
(static) invalidFunctionReturn()
This function should be called from the body of a function table
to indicate the function will not return a valid value. (The actual invalid value
can not be returned since this typically will not have the desired effect.)
(static) jsonCopy(data) → {JSON}
This method creates a deep copy of an object, array or value. Note that
undefined is not a valid value in JSON.
Parameters:
Name | Type | Description |
---|---|---|
data |
JSON | This is a JSON valued object |
Returns:
A JSON object which is a deep copy of the input.
- Type
- JSON
(static) jsonEquals(json1, json1) → {Boolean}
This is a not-so-efficient equals for json objects. For JSON objects it
does not require order matching of the keys. For JSON arrays it does require
order matching of the array values.
Parameters:
Name | Type | Description |
---|---|---|
json1 |
JSON | This is a JSON valued object |
json1 |
JSON | This is a JSON valued object |
Returns:
- Returns whether or not the objects are equal
- Type
- Boolean
(static) jsonObjectLength()
This method counts the properties in a object.
(static) jsonRequest(url, options) → {Promise}
This method returns a promise object for an HTTP request. The promist object
returns the JSON body of the URL if it resolves successfully.
Parameters:
Name | Type | Description |
---|---|---|
url |
String | This is the url to be requested |
options |
Object | These are options for the request. See apogeeutil.callbackRequest for the options definition. |
Returns:
This method returns a promise object with the URL body as text.
- Type
- Promise
(static) objectHash(object) → {integer}
This method creates an integer hash value for a JSON object.
Parameters:
Name | Type | Description |
---|---|---|
object |
JSON | This is the json valued object for which a hash number is desired. |
Returns:
This is the hash value for the JSON.
- Type
- integer
(static) parseStringArray()
This methdo parses an arg list string to make an arg list array. It is
also used outisde this class.
(static) readQueryField(field, url) → {String}
This method reads the query string from a url
Parameters:
Name | Type | Description |
---|---|---|
field |
String | This is the field that should be read from the url query string |
url |
String | This is the url from which we read the query string |
Returns:
The value associated with the query string key passed in.
- Type
- String
(static) stringHash(string) → {integer}
This method creates an integer hash value for a string.
Parameters:
Name | Type | Description |
---|---|---|
string |
String | This is the string for which a hash number is desired. |
Returns:
This is the hash value for the string.
- Type
- integer
(static) textRequest(url, options) → {Promise}
This method returns a promise object for an HTTP request. The promist object
returns the text body of the URL if it resolves successfully.
Parameters:
Name | Type | Description |
---|---|---|
url |
String | This is the url to be requested |
options |
Object | These are options for the request. See apogeeutil.callbackRequest for the options definition. |
Returns:
This method returns a promise object with the URL body as text.
- Type
- Promise