# lib/built-in.jsx

The file defines the APIs of the built-in objects of JSX, designed to be compatible to the 3rd edition of the ECMA-262 standard whenever possible.

The description of the API is based on the MDN JavaScript Reference under the Creative Commons: Attribution-Sharealike license.

## final class Map.<T>

Map is an associative container that contains a list of unique key-value pairs. Type of the keys are strings, type of the values are Nullable.<T>.

### final function hasOwnProperty(key : string) : boolean

Returns a boolean indicating whether the object has the specified property.

key | The name of the property to test.

### final function keys() : Array.<string>

Returns an array of keys of the map.

## final class Array.<T>

Array is a sequence of Nullable.<T> values. The size of an array is not fixed.

Unless otherwise noted, the defintions of the methods match those specified in ECMA-262, 3rd edition.

### var length : number

A positive integer between 0 and a value less than 232 that specifies the number of elements in an array.

You can set the length property to truncate an array at any time. When you extend an array by changing its length property, the created elements are initialized to null.

### new Array()

Constructs an empty array.

### new Array(length : number)

Constructs an array of given length. The elements are initialized to null.

### final override function toString() : string

Returns a string representing the object.

### final function toLocaleString() : string

Returns a string representing the object.

### final function concat(arrayN : ...Array.<T>) : Array.<T>

Returns a new array comprised of this array joined with other array(s) and/or value(s).

arrayN | Arrays to concatenate to the resulting array.

### final function join() : string

Joins all elements of an array into a string, separating each element with a comma.

### final function join(separator : string) : string

Joins all elements of an array into a string.

separator | Specifies a string to separate each element of the array.

### final function pop() : Nullable.<T>

Removes the last element from an array and returns that element.

### final function push(itemN : ...Nullable.<T>) : int

Mutates an array by appending the given elements and returning the new length of the array.

itemN | The elements to add to the end of the array.

### final function reverse() : Array.<T>

Reverses an array in place. The first array element becomes the last and the last becomes the first.

### final function shift() : Nullable.<T>

Removes the first element from an array and returns that element. This method changes the length of the array.

### final function slice(start : number) : Array.<T>

Returns a one-level deep copy of a portion of an array.

start | Zero-based index at which to begin extraction.

### final function slice(start : number, end : number) : Array.<T>

Returns a one-level deep copy of a portion of an array.

start | Zero-based index at which to begin extraction.
end | Zero-based index at which to end extraction. slice extracts up to but not including end.

### final function sort() : Array.<T>

Sorts the elements of an array in place and returns the array. The sort is not necessarily stable. The array is sorted lexicographically (in dictionary order) according to the string conversion of each element.

### final function sort(comparefn : function (:Nullable.<T>, :Nullable.<T>) : number) : Array.<T>

Sorts the elements of an array in place and returns the array. The sort is not necessarily stable.

comparefn | Specifies a function that defines the sort order.

### final function splice(start : number, deleteCount : number, itemN : ...T) : Array.<T>

Changes the content of an array, adding new elements while removing old elements.

start | Index at which to start changing the array. If negative, will begin that many elements from the end.
deleteCount | An integer indicating the number of old array elements to remove.
itemN | The elements to add to the array. If you don't specify any elements, `splice` simply removes elements from the array.

### final function unshift(itemN : ...Nullable.<T>) : int

Adds one or more elements to the beginning of an array and returns the new length of the array.

itemN | The elements to add to the front of the array.

### final function indexOf(value : Nullable.<T>) : number

Returns the first index at which a given element can be found in the array, or -1 if it is not present.

### final function indexOf(value : Nullable.<T>, fromIndex : number) : number

### final function lastIndexOf(value : Nullable.<T>) : number

Returns the last index at which a given element can be found in the array, or -1 if it is not present. The array is searched backward.

### final function lastIndexOf(value : Nullable.<T>, fromIndex : number) : number

### final function every(callbackfn : function (:Nullable.<T>) : boolean) : boolean

Tests whether all elements in the array pass the test implemented by the provided function.

### final function every(callbackfn : function (:Nullable.<T>, :number) : boolean) : boolean

### final function every(callbackfn : function (:Nullable.<T>, :number, :Array.<T>) : boolean) : boolean

### final function some(callbackfn : function (:Nullable.<T>) : boolean) : boolean

Tests whether some element in the array passes the test implemented by the provided function.

### final function some(callbackfn : function (:Nullable.<T>, :number) : boolean) : boolean

### final function some(callbackfn : function (:Nullable.<T>, :number, :Array.<T>) : boolean) : boolean

### final inline function forEach(callbackfn : function (:Nullable.<T>) : void) : void

Calls callbackfn once for each element in the array, in ascending order.

callbackfn | A function to call for each element.

### final function forEach(callbackfn : function (:Nullable.<T>, :number) : void) : void

### final function forEach(callbackfn : function (:Nullable.<T>, :number, :Array.<T>) : void) : void

### final function map.<U>(callbackfn : function (:Nullable.<T>) : Nullable.<U>) : Array.<U>

Creates a new array with the results of calling a provided function on every element in this array.

callbackfn | A function that produces an element of the new `Array.<U>` from an element of the current one.

### final function map.<U>(callbackfn : function (:Nullable.<T>, :number) : Nullable.<U>) : Array.<U>

### final function map.<U>(callbackfn : function (:Nullable.<T>, :number, :Array.<T>) : Nullable.<U>) : Array.<U>

### final function filter(callbackfn : function (:Nullable.<T>) : boolean) : Array.<T>

Creates a new array with all elements that pass the test implemented the provided function.

callbackfn | A function to test each elements of the array.

### final function filter(callbackfn : function (:Nullable.<T>, :number) : boolean) : Array.<T>

### final function filter(callbackfn : function (:Nullable.<T>, :number, :Array.<T>) : boolean) : Array.<T>

### final function reduce(callbackfn : function (:Nullable.<T>, :Nullable.<T>) : Nullable.<T>) : Array.<T>

Apply a function against an accumulator and each value of the array (from left-to-right) as to reduce it to a single value. `reduce` will throw `TypeError` if the array contains no elements and no initialValue is suplied.

callbackfn | A function to execute on each value in the element, taking four arguments: the previousValue (the value previously returned in the last invocation of the callback), the currentValue (the current element being processed in the array), the currentIndex and the array.

### final function reduce(callbackfn : function (:Nullable.<T>, :Nullable.<T>, :number) : Nullable.<T>) : Array.<T>

### final function reduce(callbackfn : function (:Nullable.<T>, :Nullable.<T>, :number, :Array.<T>) : Nullable.<T>) : Array.<T>

### final function reduce(callbackfn : function (:Nullable.<T>, :Nullable.<T>) : Nullable.<T>, initialValue : T) : Array.<T>

### final function reduce(callbackfn : function (:Nullable.<T>, :Nullable.<T>, :number) : Nullable.<T>, initialValue : T) : Array.<T>

### final function reduce(callbackfn : function (:Nullable.<T>, :Nullable.<T>, :number, :Array.<T>) : Nullable.<T>, initialValue : T) : Array.<T>

### final function reduceRight(callbackfn : function (:Nullable.<T>, :Nullable.<T>) : Nullable.<T>) : Array.<T>

Apply a function simultaneously against two values of the array (from right-to-left) as to reduce it to a single value.

### final function reduceRight(callbackfn : function (:Nullable.<T>, :Nullable.<T>, :number) : Nullable.<T>) : Array.<T>

### final function reduceRight(callbackfn : function (:Nullable.<T>, :Nullable.<T>, :number, :Array.<T>) : Nullable.<T>) : Array.<T>

### final function reduceRight(callbackfn : function (:Nullable.<T>, :Nullable.<T>) : Nullable.<T>, initialValue : T) : Array.<T>

### final function reduceRight(callbackfn : function (:Nullable.<T>, :Nullable.<T>) : Nullable.<T>, initialValue : T, currentIndex : number) : Array.<T>

### final function reduceRight(callbackfn : function (:Nullable.<T>, :Nullable.<T>) : Nullable.<T>, initialValue : T, currentIndex : number, array : Array.<T>) : Array.<T>

## class Object

The root class of all classes.

### new Object()

### function toString() : string

Returns a string representing the object.

## final class Function

A class representing a static function. Unlike JavaScript, JSX does not provide Function#call() or Function#apply() since it is a statically-typed language.

## final class String

A wrapper object for primitive `string`s.

Unless otherwise noted, the defintions of the methods match those specified in ECMA-262, 3rd edition.

### var length : int

The length of a string.

### new String()

Constructs a String object containing an empty string.

### new String(s : string)

Constructs a String object wrapping the given string.

### new String(s : String)

Constructs a String object wrapping the value wrapped by the given object.

### static final function fromCharCode(charN : ...number) : string

Returns a string value containing as many characters as the number of arguments.

### final override function toString() : string

Returns this string value. (Note that, for a String object, the toString method happens to return the same thing as the valueOf method.)

### final function valueOf() : string

Returns this string value.

### final function charAt(pos : number) : string

Returns a string containing the character at position `pos` in the string resulting from converting this object to a string. If there is no character at that position, the result is the empty string. The result is a string value, not a String object.

### final function charCodeAt(pos : number) : number

Returns a number (a nonnegative integer less than 216) representing the code point value of the character at position pos in the string resulting from converting this object to a string. If there is no character at that position, the result is NaN.

### final function concat(stringN : ...string) : string

When the `concat` method is called with zero or more arguments `string1`, `string2`, etc., it returns a string consisting of the characters of this object followed by the characters of each of string1, string2, etc. The result is a string value, not a String object.

### final function indexOf(searchString : string) : int

If searchString appears as a substring of the result of converting this object to a string then the index of the smallest such position is returned; otherwise, -1 is returned.

### final function indexOf(searchString : string, position : number) : int

If searchString appears as a substring of the result of converting this object to a string, at one or more positions that are greater than or equal to position, then the index of the smallest such position is returned; otherwise, -1 is returned.

### final function lastIndexOf(searchString : string) : int

If searchString appears as a substring of the result of converting this object to a string then the index of the greatest such position is returned; otherwise, -1 is returned.

### final function lastIndexOf(searchString : string, position : number) : int

If searchString appears as a substring of the result of converting this object to a string at one or more positions that are smaller than or equal to position, then the index of the greatest such position is returned; otherwise, -1 is returned.

### final function localeCompare(that : string) : number

Returns a number indicating whether a reference string comes before or after or is the same as the given string in sort order. Returns a number indicating whether a reference string comes before or after or is the same as the given string in sort order. Returns a negative number if the string occurs earlier in a sort than compareString, returns a positive number if the string occurs afterwards in such a sort, and returns 0 if they occur at the same level.

that | The string against which the referring string is comparing.

### final function match(regexp : RegExp) : Array.<string>

Used to retrieve the matches when matching a string against a regular expression. If the regular expression does not include the g flag, returns the same result as regexp.exec(string). If the regular expression includes the g flag, the method returns an Array containing all matches. If there were no matches, the method returns null. The returned Array has an extra input property, which contains the regexp that generated it as a result. In addition, it has an index property, which represents the zero-based index of the match in the string.

regexp | A regular expression object.

### final function replace(searchValue : string, replaceValue : string) : string

Returns a new string with some or all matches of a pattern replaced by a replacement.

### final function replace(searchValue : RegExp, replaceValue : string) : string

Returns a new string with some or all matches of a pattern replaced by a replacement.

### final function replace(searchValue : string, replaceValue : function (:string) : string) : string

Returns a new string with some or all matches of a pattern replaced by a replacement.

### final function replace(searchValue : RegExp, replaceValue : function (:string) : string) : string

Returns a new string with some or all matches of a pattern replaced by a replacement.

### final function search(searchValue : string) : int

Executes the search for a match between a regular expression and this `String` object.

### final function search(searchValue : RegExp) : int

Executes the search for a match between a regular expression and this `String` object.

### final function slice(start : number) : string

Extracts a section of a string and returns a new string.

start | The zero-based index at which to begin extraction.

### final function slice(start : number, end : number) : string

Extracts a section of a string and returns a new string.

start | The zero-based index at which to begin extraction.
end | The zero-based index at which to end extraction.

### final function split(separator : string) : Array.<string>

Splits a String object into an array of strings by separating the string into substrings.

separator | Specifies the character sequence to use for separating the string.

### final function split(separator : string, limit : number) : Array.<string>

Splits a String object into an array of strings by separating the string into substrings.

separator | Specifies the character sequence to use for separating the string.
limit | Integer specifying a limit on the number of splits to be found. The `split` method still splits on every match of `separator`, but it truncates the returned array to at most `limit` elements.

### final function split(separator : RegExp) : Array.<string>

Splits a String object into an array of strings by separating the string into substrings.

separator | Specifies an regular expression to use for separating the string.

### final function split(separator : RegExp, limit : number) : Array.<string>

Splits a String object into an array of strings by separating the string into substrings.

separator | Specifies an regular expression to use for separating the string.
limit | Integer specifying a limit on the number of splits to be found. The `split` method still splits on every match of `separator`, but it truncates the returned array to at most `limit` elements.

### final function substring(start : number) : string

Returns a subset of a `string` starting at the given offset.

start | The zero-based index at which to begin extraction.

### final function substring(start : number, end : number) : string

Returns a subset of a `string` starting at the given offset.

start | The zero-based index at which to begin extraction.
end | The zero-based index at which to end extraction.

### final function toLowerCase() : string

Returns the calling string value converted to lowercase.

### final function toLocaleLowerCase() : string

Returns the calling string value converted to lowercase.

### final function toUpperCase() : string

Returns the calling string value converted to uppercase.

### final function toLocaleUpperCase() : string

Returns the calling string value converted to uppercase.

### final function trim() : string

Removes whitespace from both ends of the string.

### static final function encodeURIComponent(str : string) : string

Encodes a Uniform Resource Identifier (URI) component by replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character.

str | A component of a URI.

### static final function decodeURIComponent(encodedURI : string) : string

Decodes a Uniform Resource Identifier (URI) component previously created by encodeURIComponent or by a similar routine.

encodedURI | An encoded component of a Uniform Resource Identifier.

### static final function encodeURI(str : string) : string

Encodes a Uniform Resource Identifier (URI) by replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character.

str | A complete Uniform Resource Identifier.

### static final function decodeURI(encodedURI : string) : string

Decodes a Uniform Resource Identifier (URI) previously created by encodeURI or by a similar routine.

encodedURI | A complete, encoded Uniform Resuorce Identifier.

## final class Boolean

A wrapper object for primitive `boolean`s.

### new Boolean()

Constructs a Boolean object containing a `false`.

### new Boolean(value : boolean)

Constructs a Boolean object wrapping the given value.

### new Boolean(value : Boolean)

Constructs a Boolean object wrapping the value wrapped by the given object.

### final override function toString() : string

Returns a string of either "true" or "false" depending upon the value of the object.

### final function valueOf() : boolean

Returns the wrapped `boolean` value.

## final class Number

A wrapper object for primitive `number`s.

### static const var MAX_VALUE : number

The maximum numeric value representable.

### static const var MIN_VALUE : number

The minimum numeric value representable.

### new Number()

Constructs a Number object containing `0.0`.

### new Number(value : number)

Constructs a Number object wrapping the given value.

### new Number(value : Number)

Constructs a Number object wrapping the value wrapped by the given object.

### final override function toString() : string

Returns a string representing the number.

### final function toString(radix : number) : string

Returns a string representing the number.

radix | An integer between 2 and 36 specifying the base to use for representing numeric values.

### final function toLocaleString() : string

This method available to numbers will convert the number into a string which is suitable for presentation in the given locale.

### final function valueOf() : number

Returns the wrapped `number` value.

### final function toFixed(fractionDigits : number) : string

Formats a number using fixed-point notation.

### final function toExponential(fractionDigits : number) : string

Returns a string representing the Number object in exponential notation.

### final function toPrecision(precision : number) : string

Returns a string representing the Number object to the specified precision.

### static final function parseInt(str : string) : number

Parses a string argument and returns an integer if successful, or `NaN` if failed.

str | The value to parse. Leading whitespace in the string is ignored.

### static final function parseInt(str : string, radix : number) : number

Parses a string argument and returns an integer if successful, or `NaN` if failed.

str | The value to parse. Leading whitespace in the string is ignored.
radix | An integer that represents the radix of the above mentioned string.

### static final function parseFloat(str : string) : number

Parses a string argument and returns a floating point number.

If it encounters a character other than a sign (+ or -), numeral (0-9), a decimal point, or an exponent, it returns the value up to that point and ignores that character and all succeeding characters. Leading and trailing spaces are allowed.

If the first character cannot be converted to a number, parseFloat returns `NaN`.

### static final function isNaN(num : number) : boolean

Determines whether a number is `NaN` or not.

### static final function isFinite(num : number) : boolean

Determines whether a number is finite or not.

## final class Math

Provides mathmetical constants and functions.

Unless otherwise noted, the defintions of the methods match those specified in ECMA-262, 3rd edition.

### static const var E : number

Euler's constant and the base of natural logarithms, approximately 2.718.

### static const var LN10 : number

Natural logarithm of 10, approximately 2.302.

### static const var LN2 : number

Natural logarithm of 2, approximately 0.693.

### static const var LOG2E : number

Base 2 logarithm of E, approximately 1.442.

### static const var LOG10E : number

Base 10 logarithm of E, approximately 0.434.

### static const var PI : number

Ratio of the circumference of a circle to its diameter, approximately 3.14159.

### static const var SQRT1_2 : number

Square root of 1/2; equivalently, 1 over the square root of 2, approximately 0.707.

### static const var SQRT2 : number

Square root of 2, approximately 1.414.

### static final function abs(x : number) : number

Returns the absolute value of a number.

### static final function acos(x : number) : number

### static final function asin(x : number) : number

### static final function atan(x : number) : number

### static final function atan2(y : number, x : number) : number

### static final function ceil(x : number) : number

### static final function cos(x : number) : number

### static final function exp(x : number) : number

### static final function floor(x : number) : number

### static final function log(x : number) : number

### static final function max(value1 : number, value2 : number, value3 : number, valueN : ...number) : number

### static final function max(value1 : number) : number

### static final function min(value1 : number, value2 : number, value3 : number, valueN : ...number) : number

### static final function min(value1 : number) : number

### static final function pow(x : number, y : number) : number

### static final function random() : number

### static final function round(x : number) : number

### static final function sin(x : number) : number

### static final function sqrt(x : number) : number

### static final function tan(x : number) : number

### static final function max(value1 : number, value2 : number) : number

### static final function min(value1 : number, value2 : number) : number

## final class Date

An object for working with dates and times.

Unless otherwise noted, the defintions of the methods match those specified in ECMA-262, 3rd edition.

### new Date(year : number, month : number)

Creates a Date object.

### new Date(year : number, month : number, date : number)

Creates a Date object.

### new Date(year : number, month : number, date : number, hours : number)

Creates a Date object.

### new Date(year : number, month : number, date : number, hours : number, minutes : number)

Creates a Date object.

### new Date(year : number, month : number, date : number, hours : number, minutes : number, seconds : number)

Creates a Date object.

### new Date(year : number, month : number, date : number, hours : number, minutes : number, seconds : number, ms : number)

Creates a Date object.

### new Date(value : string)

Creates a Date object.

value | String value representing a date. The string should be in a format recognized by the `parse` method (IETF-compliant RFC 2822 timestamps).

### new Date(value : number)

Creates a Date object.

value | Integer value representing the number of milliseconds since 1 January 1970 00:00:00 UTC (Unix Epoch).

### new Date(value : Date)

Clones the given object.

### new Date()

Creates a Date object for today's date and time according to local time.

### static final function parse(value : string) : number

### static final function UTC(year : number, month : number) : number

### static final function UTC(year : number, month : number, date : number) : number

### static final function UTC(year : number, month : number, date : number, hours : number) : number

### static final function UTC(year : number, month : number, date : number, hours : number, minutes : number) : number

### static final function UTC(year : number, month : number, date : number, hours : number, minutes : number, seconds : number) : number

### static final function UTC(year : number, month : number, date : number, hours : number, minutes : number, seconds : number, ms : number) : number

### static final function now() : number

### final override function toString() : string

### final function toDateString() : string

### final function toTimeString() : string

### final function toLocaleString() : string

### final function toLocaleDateString() : string

### final function toLocaleTimeString() : string

### final function valueOf() : number

### final function getTime() : number

### final function getFullYear() : number

### final function getUTCFullYear() : number

### final function getMonth() : number

### final function getUTCMonth() : number

### final function getDate() : number

### final function getUTCDate() : number

### final function getDay() : number

### final function getUTCDay() : number

### final function getHours() : number

### final function getUTCHours() : number

### final function getMinutes() : number

### final function getUTCMinutes() : number

### final function getSeconds() : number

### final function getUTCSeconds() : number

### final function getMilliseconds() : number

### final function getUTCMilliseconds() : number

### final function getTimezoneOffset() : number

### final function setTime(time : number) : number

### final function setMilliseconds(ms : number) : number

### final function setUTCMilliseconds(ms : number) : number

### final function setSeconds(sec : number) : number

### final function setUTCSeconds(sec : number) : number

### final function setMinutes(min : number) : number

### final function setUTCMinutes(min : number) : number

### final function setHours(hour : number) : number

### final function setUTCHours(hour : number) : number

### final function setDate(date : number) : number

### final function setUTCDate(date : number) : number

### final function setMonth(month : number) : number

### final function setUTCMonth(month : number) : number

### final function setFullYear(year : number) : number

### final function setUTCFullYear(year : number) : number

### final function toUTCString() : string

### final function toISOString() : string

### final function toJSON() : string

### final function toJSON(key : string) : string

## final class RegExp

An object that represents a regular-expression.

Unless otherwise noted, the defintions of the methods match those specified in ECMA-262, 3rd edition.

### var source : string

### var global : boolean

### var ignoreCase : boolean

### var multiline : boolean

### var lastIndex : int

### new RegExp(pattern : string, flags : string)

### new RegExp(pattern : string)

### new RegExp(pattern : RegExp)

### final function exec(str : string) : Array.<string>

### final function test(str : string) : boolean

### final override function toString() : string

## class Error

### var name : string

### var message : string

### var stack : string

Implementation-dependent stack trace information

### new Error()

### new Error(message : string)

## class EvalError

### new EvalError()

### new EvalError(message : string)

## class RangeError

### new RangeError()

### new RangeError(message : string)

## class ReferenceError

### new ReferenceError()

### new ReferenceError(message : string)

## class SyntaxError

### new SyntaxError()

### new SyntaxError(message : string)

## class TypeError

### new TypeError()

### new TypeError(message : string)

## final class JSON

Provides static functions to manipulate JSON.

Unless otherwise noted, the defintions of the methods match those specified in ECMA-262, 5th edition.

### static final function parse(text : string) : variant

### static final function parse(text : string, reviver : function (:string, :variant) : variant) : variant

### static final function stringify(value : variant) : string

### static final function stringify(value : variant, replacer : function (:string, :variant) : variant) : string

### static final function stringify(value : variant, replacer : function (:string, :variant) : variant, space : number) : string

## final class JSX

Provides static functions to control the behaviour of the JSX runtime.

### static const var DEBUG : boolean

A flag which is disabled by `--optimize no-debug`.
This is intended to remove debugging statements on release build.

### static final function profilerIsRunning() : boolean

Returns whether or not the profiler is running.

### static final function getProfileResults() : variant

Returns the profiler results.

### static final function postProfileResults(url : string) : void

Posts the profiler results to the given URL.

Please refer to the profiler document for using the function.

### static final function postProfileResults(url : string, cb : function (:Error, :string) : void) : void

### static final function resetProfileResults() : void

Resets the collected profiler results.