Class Index | File Index

Classes


Namespace ilib

The global namespace that contains all ilib functions and classes.
Defined in: ilib-dyn-full.js.

Namespace Summary
Constructor Attributes Constructor Name and Description
 
Field Summary
Field Attributes Field Name and Description
<static>  
ilib.data
Place where resources and such are eventually assigned.
Method Summary
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>  
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)
Namespace Detail
ilib
Field Detail
<static> ilib.data
Place where resources and such are eventually assigned.
Method Detail
<static> ilib.amod(dividend, modulus)
Do a proper adjusted modulo function. The Javascript % operator will give the truncated division algorithm, but for calendrical calculations, we need the Euclidean division algorithm where the remainder of any division, whether the dividend is negative or not, is always a positive number in the range (0, modulus]. The adjusted modulo function differs from the regular modulo function in that when the remainder is zero, the modulus should be returned instead.

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.

<static> {function(...)|undefined} 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. bind() doesn't exist in many older browsers.
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

<static> ilib.bisectionSearch(target, low, high, precision, func)
Do a bisection search of a function for a particular target value.

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

<static> ilib.bsearch(target, arr, comparator)
Binary search a sorted array for a particular target value. If the exact value is not found, it returns the index of the smallest entry that is greater than the given target value.

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

<static> ilib.Cal()
Interface that all calendars must implement. Depends directive: !depends calendar.js

<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]
Parameters:
from
to

<static> {string} ilib.getLocale()
Return the default locale for all of ilib if one has been set. This locale will be used when no explicit locale is passed to any ilib class. If the default locale is not set, ilib will attempt to use the locale of the environment it is running in, if it can find that. If not, it will default to the locale "en-US".

Depends directive: !depends ilibglobal.js

Returns:
{string} the locale specifier for the default locale

<static> {Array.<string>} ilib.getLocFiles(locale, name)
Return an array of relative path names for the files that represent the data for the given 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/region
With only language and script specified:

language
language/script
With only script and region specified:

und/region  
With only region and variant specified:

und/region
region/variant
With only language, script, and region specified:

language
und/region
language/script
language/region
language/script/region
With only language, region, and variant specified:

language
und/region
language/region
region/variant
language/region/variant
With 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

<static> {string} ilib.getTimeZone()
Return the default time zone for all of ilib if one has been set. This time zone will be used when no explicit time zone is passed to any ilib class. If the default time zone is not set, ilib will attempt to use the locale of the environment it is running in, if it can find that. If not, it will default to the the zone "local".

Depends directive: !depends ilibglobal.js

Returns:
{string} the default time zone for ilib

<static> {string} ilib.getVersion()
Return the current version of ilib.
Returns:
{string} a version string for this instance of ilib

<static> {number} ilib.indexOf(array, obj)
Check if an object is a member of the given array. If this javascript engine support indexOf, it is used directly. Otherwise, this function implements it itself. The idea is to make sure that you can use the quick indexOf if it is available, but use a slower implementation in older engines as well.
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.

<static> {boolean} ilib.isEmpty(obj)
Return true if the given object has no properties.

Depends directive: !depends utils.js

Parameters:
{Object} obj
the object to check
Returns:
{boolean} true if the given object has no properties, false otherwise

<static> ilib.loadData(params)
Find locale data or load it in. If the data with the given name is preassembled, it will find the data in ilib.data. If the data is not preassembled but there is a loader function, this function will call it to load the data. Otherwise, the callback will be called with undefined as the data. This function will create a cache under the given class object. If data was successfully loaded, it will be set into the cache so that future access to the same data for the same locale is much quicker.

The parameters can specify any of the following properties:

Parameters:
{Object} params
Parameters configuring how to load the files (see above)

<static> {string} ilib.mapString(str, map)
Map a string to the given set of alternate characters. If the target set does not contain a particular character in the input string, then that character will be copied to the output unmapped.
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

<static> {Object} ilib.merge(object1, object2, replace, name1, name2)
Merge the properties of object2 into object1 in a deep manner and return a merged object. If the property exists in both objects, the value in object2 will overwrite the value in object1. If a property exists in object1, but not in object2, its value will not be touched. If a property exists in object2, but not in object1, it will be added to the merged result.

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

<static> {Object?} 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. This merges the data in the correct order:
  1. shared data (usually English)
  2. data for language
  3. data for language + region
  4. data for language + region + script
  5. data for language + region + script + variant
It is okay for any of the above to be missing. This function will just skip the missing data. However, if everything except the shared data is missing, this function returns undefined, allowing the caller to go and dynamically load the data instead.
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

<static> ilib.mod(dividend, modulus)
Do a proper modulo function. The Javascript % operator will give the truncated division algorithm, but for calendrical calculations, we need the Euclidean division algorithm where the remainder of any division, whether the dividend is negative or not, is always a positive number in the range [0, modulus).

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.

<static> ilib.setAsPseudoLocale(localename)
Sets the pseudo locale. Pseudolocalization (or pseudo-localization) is used for testing internationalization aspects of software. Instead of translating the text of the software into a foreign language, as in the process of localization, the textual elements of an application are replaced with an altered version of the original language.These specific alterations make the original words appear readable, but include the most problematic characteristics of the world's languages: varying length of text or characters, language direction, and so on. Regular Latin pseudo locale: eu-ES and RTL pseudo locale: ps-AF
Parameters:
{string|undefined|null} localename
the locale specifier for the pseudo locale

<static> {boolean} ilib.setLoaderCallback(loader)
Set the custom loader used to load ilib's locale data in your environment. The instance passed in must implement the ilib.Loader interface. See the ilib.Loader class documentation for more information about loaders.
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

<static> ilib.setLocale(spec)
Sets the default locale for all of ilib. This locale will be used when no explicit locale is passed to any ilib class. If the default locale is not set, ilib will attempt to use the locale of the environment it is running in, if it can find that. If not, it will default to the locale "en-US". If a type of parameter is string, ilib will take only well-formed BCP-47 tag

Depends directive: !depends ilibglobal.js

Parameters:
{string|undefined|null} spec
the locale specifier for the default locale

<static> ilib.setTimeZone(tz)
Sets the default time zone for all of ilib. This time zone will be used when no explicit time zone is passed to any ilib class. If the default time zone is not set, ilib will attempt to use the time zone of the environment it is running in, if it can find that. If not, it will default to the the UTC zone "Etc/UTC".

Depends directive: !depends ilibglobal.js

Parameters:
{string} tz
the name of the time zone to set as the default time zone

<static> ilib.shallowCopy(source, target)
Perform a shallow copy of the source object to the target object. This only copies the assignments of the source properties to the target properties, but not recursively from there.

Depends directive: !depends utils.js

Parameters:
{Object} source
the source object to copy properties from
{Object} target
the target object to copy properties into

<static> {number} ilib.signum(num)
Return the sign of the given number. If the sign is negative, this function returns -1. If the sign is positive or zero, this function returns 1.
Parameters:
{number} num
the number to test
Returns:
{number} -1 if the number is negative, and 1 otherwise

<static> {string} ilib.toHexString(string, limit)
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

Documentation generated by JsDoc Toolkit 2.4.0 on Tue Feb 02 2016 16:00:48 GMT-0800 (PST)