Namespace ilib
The global namespace that contains all ilib functions and classes.
Defined in: ilib-dyn-full.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Field Attributes | Field Name and Description |
---|---|
<static> |
ilib.data
Place where resources and such are eventually assigned.
|
Method Attributes | Method Name and Description |
---|---|
<static> |
ilib.amod(dividend, modulus)
Do a proper adjusted modulo function.
|
<static> |
ilib.bind(scope, method)
If Function.prototype.bind does not exist in this JS engine, this
function reimplements it in terms of older JS functions.
|
<static> |
ilib.bisectionSearch(target, low, high, precision, func)
Do a bisection search of a function for a particular target value.
|
<static> |
ilib.bsearch(target, arr, comparator)
Binary search a sorted array for a particular target value.
|
<static> |
ilib.Cal()
Interface that all calendars must implement.
|
<static> |
ilib.clearPseudoLocales()
Reset the list of pseudo locales back to the default single locale of zxx-XX.
|
<static> |
ilib.deepCopy(from, to)
[Need Comment]
|
<static> |
ilib.getLocale()
Return the default locale for all of ilib if one has been set.
|
<static> |
ilib.getLocFiles(locale, name)
Return an array of relative path names for the
files that represent the data for the given locale.
|
<static> |
ilib.getTimeZone()
Return the default time zone for all of ilib if one has been set.
|
<static> |
ilib.getVersion()
Return the current version of ilib.
|
<static> |
ilib.indexOf(array, obj)
Check if an object is a member of the given array.
|
<static> |
ilib.isEmpty(obj)
Return true if the given object has no properties.
|
<static> |
ilib.loadData(params)
Find locale data or load it in.
|
<static> |
ilib.mapString(str, map)
Map a string to the given set of alternate characters.
|
<static> |
ilib.merge(object1, object2, replace, name1, name2)
Merge the properties of object2 into object1 in a deep manner and return a merged
object.
|
<static> |
ilib.mergeLocData(prefix, locale, replaceArrays, returnOne)
Find and merge all the locale data for a particular prefix in the given locale
and return it as a single javascript object.
|
<static> |
ilib.mod(dividend, modulus)
Do a proper modulo function.
|
<static> |
ilib.setAsPseudoLocale(localename)
Sets the pseudo locale.
|
<static> |
ilib.setLoaderCallback(loader)
Set the custom loader used to load ilib's locale data in your environment.
|
<static> |
ilib.setLocale(spec)
Sets the default locale for all of ilib.
|
<static> |
ilib.setTimeZone(tz)
Sets the default time zone for all of ilib.
|
<static> |
ilib.shallowCopy(source, target)
Perform a shallow copy of the source object to the target object.
|
<static> |
ilib.signum(num)
Return the sign of the given number.
|
<static> |
ilib.toHexString(string, limit)
|
Depends directive: !depends utils.js
- Parameters:
- {number} dividend
- the number being divided
- {number} modulus
- the number dividing the dividend. This should always be a positive number.
- Returns:
- the remainder of dividing the dividend by the modulus.
- Parameters:
- {Object} scope
- object that the method should operate on
- {function(...)} method
- method to call
- Returns:
- {function(...)|undefined} function that calls the given method in the given scope with all of its arguments properly attached, or undefined if there was a problem with the arguments
The function to search is a function that takes a numeric parameter, does calculations, and returns gives a numeric result. The function should should be smooth and not have any discontinuities between the low and high values of the parameter. Depends directive: !depends utils.js
- Parameters:
- {number} target
- value being sought
- {number} low
- the lower bounds to start searching
- {number} high
- the upper bounds to start searching
- {number} precision
- minimum precision to support. Use 0 if you want to use the default.
- {?function(number)=} func
- function to search
- Returns:
- an approximation of the input value to the function that gives the desired target output value, correct to within the error range of Javascript floating point arithmetic, or NaN if there was some error
The comparator parameter is a function that knows how to compare elements of the array and the target. The function should return a value greater than 0 if the array element is greater than the target, a value less than 0 if the array element is less than the target, and 0 if the array element and the target are equivalent.
If the comparator function is not specified, this function assumes the array and the target are numeric values and should be compared as such.
Depends directive: !depends utils.js
- Parameters:
- {*} target
- element being sought
- {Array} arr
- the array being searched
- {?function(*|*)=} comparator
- a comparator that is appropriate for comparing two entries in the array
- Returns:
- the index of the array into which the value would fit if inserted, or -1 if given array is not an array or the target is not a number
- Parameters:
- from
- to
Depends directive: !depends ilibglobal.js
- Returns:
- {string} the locale specifier for the default locale
Note that to prevent the situation where a directory for a language exists next to the directory for a region where the language code and region code differ only by case, the plain region directories are located under the special "undefined" language directory which has the ISO code "und". The reason is that some platforms have case-insensitive file systems, and you cannot have 2 directories with the same name which only differ by case. For example, "es" is the ISO 639 code for the language "Spanish" and "ES" is the ISO 3166 code for the region "Spain", so both the directories cannot exist underneath "locale". The region therefore will be loaded from "und/ES" instead.
Variations
With only language and region specified, the following sequence of paths will be generated:
language und/region language/regionWith only language and script specified:
language language/scriptWith only script and region specified:
und/regionWith only region and variant specified:
und/region region/variantWith only language, script, and region specified:
language und/region language/script language/region language/script/regionWith only language, region, and variant specified:
language und/region language/region region/variant language/region/variantWith all parts specified:
language und/region language/script language/region region/variant language/script/region language/region/variant language/script/region/variant
- Parameters:
- {ilib.Locale} locale
- load the files for this locale
- {string?} name
- the file name of each file to load without any path
- Returns:
- {Array.<string>} An array of relative path names for the files that contain the locale data
Depends directive: !depends ilibglobal.js
- Returns:
- {string} the default time zone for ilib
- Returns:
- {string} a version string for this instance of ilib
- Parameters:
- {Array.<Object>} array
- array to search
- {Object} obj
- object being sought. This should be of the same type as the members of the array being searched. If not, this function will not return any results.
- Returns:
- {number} index of the object in the array, or -1 if it is not in the array.
Depends directive: !depends utils.js
- Parameters:
- {Object} obj
- the object to check
- Returns:
- {boolean} true if the given object has no properties, false otherwise
The parameters can specify any of the following properties:
- name - String. The name of the file being loaded. Default: resources.json
- object - Object. The class attempting to load data. The cache is stored inside of here.
- locale - ilib.Locale. The locale for which data is loaded. Default is the current locale.
- nonlocale - boolean. If true, the data being loaded is not locale-specific.
- type - String. Type of file to load. This can be "json" or "other" type. Default: "json"
- replace - boolean. When merging json objects, this parameter controls whether to merge arrays or have arrays replace each other. If true, arrays in child objects replace the arrays in parent objects. When false, the arrays in child objects are concatenated with the arrays in parent objects.
- loadParams - Object. An object with parameters to pass to the loader function
- sync - boolean. Whether or not to load the data synchronously
- callback - function(?)=. callback Call back function to call when the data is available. Data is not returned from this method, so a callback function is mandatory.
- Parameters:
- {Object} params
- Parameters configuring how to load the files (see above)
- Parameters:
- {string} str
- a string to map to an alternate set of characters
- {Array.<string>|Object} map
- a mapping to alternate characters
- Returns:
- {string} the source string where each character is mapped to alternate characters
Name1 and name2 are for creating debug output only. They are not necessary.
Depends directive: !depends utils.js
- Parameters:
- {*} object1
- the object to merge into
- {*} object2
- the object to merge
- {boolean=} replace
- if true, replace the array elements in object1 with those in object2. If false, concatenate array elements in object1 with items in object2.
- {string=} name1
- name of the object being merged into
- {string=} name2
- name of the object being merged in
- Returns:
- {Object} the merged object
- shared data (usually English)
- data for language
- data for language + region
- data for language + region + script
- data for language + region + script + variant
- Parameters:
- {string} prefix
- prefix under ilib.data of the data to merge
- {ilib.Locale} locale
- locale of the data being sought
- {boolean=} replaceArrays
- if true, replace the array elements in object1 with those in object2. If false, concatenate array elements in object1 with items in object2.
- {boolean=} returnOne
- if true, only return the most locale-specific data. If false, merge all the relevant locale data together.
- Returns:
- {Object?} the merged locale data
Depends directive: !depends utils.js
- Parameters:
- {number} dividend
- the number being divided
- {number} modulus
- the number dividing the dividend. This should always be a positive number.
- Returns:
- the remainder of dividing the dividend by the modulus.
- Parameters:
- {string|undefined|null} localename
- the locale specifier for the pseudo locale
- Parameters:
- {ilib.Loader} loader
- class to call to access the requested data.
- Returns:
- {boolean} true if the loader was installed correctly, or false if not
Depends directive: !depends ilibglobal.js
- Parameters:
- {string|undefined|null} spec
- the locale specifier for the default locale
Depends directive: !depends ilibglobal.js
- Parameters:
- {string} tz
- the name of the time zone to set as the default time zone
Depends directive: !depends utils.js
- Parameters:
- {Object} source
- the source object to copy properties from
- {Object} target
- the target object to copy properties into
- Parameters:
- {number} num
- the number to test
- Returns:
- {number} -1 if the number is negative, and 1 otherwise
- Parameters:
- {string} string
- The string to convert
- {number=} limit
- the number of digits to use to represent the character (1 to 8)
- Returns:
- {string} a hexadecimal representation of the Unicode characters in the input string