Class: Core

Core()

new Core()

MaiaScript core library.
Source:

Methods

add(left, right) → {string}

Add two objects.
Parameters:
Name Type Description
left object The left operand.
right object The right operand.
Source:
Returns:
An string represening the result of the operation.
Type
string

arrayToMatrix(obj) → {array}

Convert an array to a n x 1 matrix.
Parameters:
Name Type Description
obj array Array to be Converted.
Source:
Returns:
The array converted to a matrix.
Type
array

bitwiseAND(left, right) → {string}

Performs the binary AND operation between two objects.
Parameters:
Name Type Description
left object The left operand.
right object The right operand.
Source:
Returns:
An string represening the result of the operation.
Type
string

bitwiseNot(right) → {string}

Performs a binary NOT operation.
Parameters:
Name Type Description
right object The right operand.
Source:
Returns:
An string represening the result of the operation.
Type
string

bitwiseOR(left, right) → {string}

Performs the binary OR operation between two objects.
Parameters:
Name Type Description
left object The left operand.
right object The right operand.
Source:
Returns:
An string represening the result of the operation.
Type
string

bitwiseXOR(left, right) → {string}

Performs the binary XOR operation between two objects.
Parameters:
Name Type Description
left object The left operand.
right object The right operand.
Source:
Returns:
An string represening the result of the operation.
Type
string

charAt(str, pos) → {string}

Returns the character at the indicated position.
Parameters:
Name Type Description
str string The string to look for.
pos number The character position.
Source:
Returns:
The character at the indicated position.
Type
string

charCodeAt(str, pos) → {string}

Returns the character code at the indicated position.
Parameters:
Name Type Description
str string The string to look for.
pos number The character position.
Source:
Returns:
The character code at the indicated position.
Type
string

clone(obj) → {string}

Returns a clone of an object.
Parameters:
Name Type Description
obj object The object to be cloned.
Source:
Returns:
The clone of the object.
Type
string

complex(real, img) → {number}

Returns a complex number, given the real and imaginary part of the number.
Parameters:
Name Type Description
real object TThe real part of the complex number.
img number The imaginary part of the complex number.
Source:
Returns:
A complex complex number.
Type
number

concat(mtx1, mtx2) → {array}

Join two matrices.
Parameters:
Name Type Description
mtx1 array The first matrix.
mtx2 array The second matrix.
Source:
Returns:
Matrix containing the two indicated matrices.
Type
array

conj(num) → {number}

Calculates the conjugate of a complex number.
Parameters:
Name Type Description
num number The complex number.
Source:
Returns:
the conjugate of a complex number.
Type
number

copyMatrix(obj) → {array}

Copies a matrix.
Parameters:
Name Type Description
obj array Matrix to be copied.
Source:
Returns:
A copy of the matrix.
Type
array

date() → {object}

Returns a Date object.
Source:
Returns:
A Date object.
Type
object

det(obj) → {array}

Calculates the determinant matrix.
Parameters:
Name Type Description
obj object The matrix to calculate the determinant.
Source:
Returns:
A (rows x columns) matrix.
Type
array

diag(obj) → {array}

Calculates the diagonal equivalent matrix.
Parameters:
Name Type Description
obj object The matrix to calculate the diagonal equivalent matrix.
Source:
Returns:
A (rows x columns) matrix.
Type
array

different(left, right) → {string}

Returns TRUE if two objects are different.
Parameters:
Name Type Description
left object The left operand.
right object The right operand.
Source:
Returns:
An string represening the result of the operation.
Type
string

dim(obj) → {array}

Returns the dimensions of an array.
Parameters:
Name Type Description
obj array Object to be measured.
Source:
Returns:
Array containing the dimensions of a matrix.
Type
array

div(left, right) → {string}

Divide two objects.
Parameters:
Name Type Description
left object The left operand.
right object The right operand.
Source:
Returns:
An string represening the result of the operation.
Type
string

equal(left, right) → {string}

Returns TRUE if two objects are equal.
Parameters:
Name Type Description
left object The left operand.
right object The right operand.
Source:
Returns:
An string represening the result of the operation.
Type
string

eval(stript, namespace) → {number}

Evaluates a MaiaScript script.
Parameters:
Name Type Description
stript string The script to be evaluated.
namespace object The namespace where evaluate the script.
Source:
Returns:
Result of the evaluated script.
Type
number

GE(left, right) → {string}

Returns TRUE if the object on the left is greater than or equal to the object on the right.
Parameters:
Name Type Description
left object The left operand.
right object The right operand.
Source:
Returns:
An string represening the result of the operation.
Type
string

GT(left, right) → {string}

Returns TRUE if the object on the left is greater than the object on the right.
Parameters:
Name Type Description
left object The left operand.
right object The right operand.
Source:
Returns:
An string represening the result of the operation.
Type
string

ident(rows) → {array}

Creates the identity matrix..
Parameters:
Name Type Description
rows number Number of rows in the matrix.
Source:
Returns:
A (rows x rows) identity matrix.
Type
array

imaginary(obj) → {number}

Returns the imaginary part of a complex number.
Parameters:
Name Type Description
obj object The complex number.
Source:
Returns:
The imaginary part of a complex number.
Type
number

includes(obj, text) → {boolean}

Returns true if one string is contained in another or in an array.
Parameters:
Name Type Description
obj object The string containing the other one.
text string Search string.
Source:
Returns:
True if one string is contained in another or in an array.
Type
boolean

indexOf(str, text) → {number}

Returns the position of one string in another.
Parameters:
Name Type Description
str string The string containing the other one.
text string Search string.
Source:
Returns:
The position of one string in the other.
Type
number

inv(obj) → {array}

Calculates the inverse matrix.
Parameters:
Name Type Description
obj object The matrix to calculate the inverse.
Source:
Returns:
A (rows x columns) matrix.
Type
array

join(mtx, char) → {string}

Join the elements of an array using the indicated separator.
Parameters:
Name Type Description
mtx array The array to join elements.
char string The separator character.
Source:
Returns:
The string containing the parts of the array.
Type
string

lastIndexOf(str, text) → {number}

Returns the last position of one string in another.
Parameters:
Name Type Description
str string The string containing the other one.
text string Search string.
Source:
Returns:
The position of last occurrence of string in the other.
Type
number

LE(left, right) → {string}

Returns TRUE if the object on the left is less than or equal to the object on the right.
Parameters:
Name Type Description
left object The left operand.
right object The right operand.
Source:
Returns:
An string represening the result of the operation.
Type
string

leftShift(left, right) → {string}

Performs a left shift operation.
Parameters:
Name Type Description
left object The left operand.
right object The right operand.
Source:
Returns:
An string represening the result of the operation.
Type
string

length(obj) → {number}

Returns the size of an object.
Parameters:
Name Type Description
obj string Object to be measured.
Source:
Returns:
Object size.
Type
number

logicalAND(left, right) → {string}

Performs the logical AND operation between two objects.
Parameters:
Name Type Description
left object The left operand.
right object The right operand.
Source:
Returns:
An string represening the result of the operation.
Type
string

logicalNot(right) → {string}

Performs a logical NOT operation.
Parameters:
Name Type Description
right object The right operand.
Source:
Returns:
An string represening the result of the operation.
Type
string

logicalOR(left, right) → {string}

Performs the logical OR operation between two objects.
Parameters:
Name Type Description
left object The left operand.
right object The right operand.
Source:
Returns:
An string represening the result of the operation.
Type
string

logicalXOR(left, right) → {string}

Performs the logical XOR operation between two objects.
Parameters:
Name Type Description
left object The left operand.
right object The right operand.
Source:
Returns:
An string represening the result of the operation.
Type
string

LT(left, right) → {string}

Returns TRUE if the object on the left is smaller than the object on the right.
Parameters:
Name Type Description
left object The left operand.
right object The right operand.
Source:
Returns:
An string represening the result of the operation.
Type
string

matrix(obj, rows, columns) → {array}

Creates a two-dimensional array (matrix).
Parameters:
Name Type Description
obj object Object to fill the matrix cells.
rows number Number of rows in the matrix.
columns number Number of columns in the matrix.
Source:
Returns:
A (rows x columns) matrix.
Type
array

matrixToArray(obj) → {array}

Convert an n x 1 matrix to an array.
Parameters:
Name Type Description
obj array Matrix to be Converted.
Source:
Returns:
The matrix converted to an array.
Type
array

matrixToObject(obj, members) → {array}

Convert a matrix to an object.
Parameters:
Name Type Description
obj array Matrix to be Converted.
members array Object member names.
Source:
Returns:
The matrix converted to an object.
Type
array

mod(left, right) → {string}

Calculates the rest of the division between two objects.
Parameters:
Name Type Description
left object The left operand.
right object The right operand.
Source:
Returns:
An string represening the result of the operation.
Type
string

mul(left, right) → {string}

Multiplies two objects.
Parameters:
Name Type Description
left object The left operand.
right object The right operand.
Source:
Returns:
An string represening the result of the operation.
Type
string

new(obj, properties) → {number}

Creates a new instance of an object.
Parameters:
Name Type Description
obj object The object that will be used as a template.
properties object The object properties.
Source:
Returns:
A new instance of an object.
Type
number

one(rows, columns) → {array}

Creates a unitary matrix.
Parameters:
Name Type Description
rows number Number of rows in the matrix.
columns number Number of columns in the matrix.
Source:
Returns:
A (rows x columns) matrix.
Type
array

openSQLDatabase(name, version, displayName, estimatedSize) → {object}

Opens or creates a database.
Parameters:
Name Type Description
name string Database name.
version string Scheme version.
displayName string The display name of the database.
estimatedSize string Estimated maximum size.
Source:
Returns:
Reference to the open or created database.
Type
object

pop(mtx, obj) → {array}

Removes an object from the end of an array.
Parameters:
Name Type Description
mtx array The array to join elements.
obj object The separator character.
Source:
Returns:
The array with the object removed.
Type
array

power(left, right) → {string}

Performs a power operation between two objects.
Parameters:
Name Type Description
left object The left operand.
right object The right operand.
Source:
Returns:
An string represening the result of the operation.
Type
string

push(mtx, obj) → {array}

Insert an object at the end of an array.
Parameters:
Name Type Description
mtx array The array to join elements.
obj object The separator character.
Source:
Returns:
The array with the added object.
Type
array

real(obj) → {number}

Returns the real part of a complex number.
Parameters:
Name Type Description
obj object The complex number.
Source:
Returns:
The real part of a complex number.
Type
number

regExp(pattern, flags) → {object}

Create a RegExp object to compare an expression with a specified pattern (regular expression).
Parameters:
Name Type Description
pattern string The regular expression.
flags string Indicates the marks that can be added.
Source:
Returns:
A RegExp object.
Type
object

repeat(str, count) → {string}

Returns a new string with a specified number of copies of the string.
Parameters:
Name Type Description
str object The object to convert to do string.
count number Number of copies.
Source:
Returns:
A new string with a specified number of copies of the string.
Type
string

replace(str, string1, string2) → {string}

Replaces one character string with another in a string.
Parameters:
Name Type Description
str string The string containing the other one.
string1 string The string to search for.
string2 string The replacement string.
Source:
Returns:
A new string.
Type
string

rightShift(left, right) → {string}

Performs a left shift operation.
Parameters:
Name Type Description
left object The left operand.
right object The right operand.
Source:
Returns:
An string represening the result of the operation.
Type
string
Searches a string for a specified value.
Parameters:
Name Type Description
str string The string containing the other one.
text string Search string.
Source:
Returns:
The position of the match.
Type
number

shift(mtx, obj) → {array}

Insert an object at the beginning of an array.
Parameters:
Name Type Description
mtx array The array to join elements.
obj object The separator character.
Source:
Returns:
The array with the added object.
Type
array

slice(obj, start, end) → {string}

Return a part of a string or array.
Parameters:
Name Type Description
obj string The string or array containing the other one.
start number The start position.
end number The final position.
Source:
Returns:
The selected part of the string or array.
Type
string

splice(mtx, pos, count, obj) → {array}

Removes or replaces an object from the specified position in an array.
Parameters:
Name Type Description
mtx array The array to remove elements.
pos number Position from which objects will be removed.
count number Number of objects to remove.
obj object Object to be inserted in the specified location.
Source:
Returns:
The array with the objects removed.
Type
array

split(str, chars) → {array}

Convert a string to an array, using the character indicated as a separator.
Parameters:
Name Type Description
str string The string to slit.
chars string The separator characters.
Source:
Returns:
The array containing the parts of the string.
Type
array

splitCSV(str, separator, allowRepeatChar, doEval) → {array}

Convert a CSV record to an array, using the character indicated as the column separator.
Parameters:
Name Type Description
str string The string to slit.
separator string The separator characters.
allowRepeatChar boolean The separator character can be repeated (for formatting).
doEval boolean Run core.eval before adding the column to the record.
Source:
Returns:
The array containing the parts of the CSV or NULL if the CSV record is not well formed.
Type
array

sub(left, right) → {string}

Subtracts two objects.
Parameters:
Name Type Description
left object The left operand.
right object The right operand.
Source:
Returns:
An string represening the result of the operation.
Type
string

substr(str, start, size) → {string}

Return a part of a string.
Parameters:
Name Type Description
str string The string containing the other one.
start number The start position.
size number The the size of the slice.
Source:
Returns:
The selected part of the string.
Type
string

testScript(_script, _times, _value, _tolerance, _catchScript) → {boolean}

Tests a script, checking if the result of its execution corresponds to the expected result, considering the specified tolerance.
Parameters:
Name Type Description
_script string The script to be evaluated.
_times number Number of times the test must be repeated.
_value number Expected value.
_tolerance number Tolerance.
_catchScript string Script to be evaluated if the test fails.
Source:
Returns:
True if the test was successful or false, otherwise.
Type
boolean

toLowerCase(text) → {string}

Converts a string to lower case.
Parameters:
Name Type Description
text string The string to convert.
Source:
Returns:
A new string.
Type
string

toNumber(text) → {number}

Converts a string representing a number to a binary number.
Parameters:
Name Type Description
text string The string representing a number.
Source:
Returns:
The string coverted to number.
Type
number

toString(obj, base) → {string}

Converts an objecto to string.
Parameters:
Name Type Description
obj object The object to convert to do string.
base number Numerical base for conversion.
Source:
Returns:
The object coverted for string.
Type
string

toUpperCase(text) → {string}

Converts a string to uppercase.
Parameters:
Name Type Description
text string The string to convert.
Source:
Returns:
A new string.
Type
string

trim(str, chars) → {string}

Removes characters from the beginning and end of a string.
Parameters:
Name Type Description
str string The string to be trimmed
chars string The characters to remove.
Source:
Returns:
A new string.
Type
string

trimLeft(str, chars) → {string}

Removes characters from the beginning and end of a string.
Parameters:
Name Type Description
str string The string to be trimmed
chars string The characters to remove.
Source:
Returns:
A new string.
Type
string

trimRight(str, chars) → {string}

Removes characters from the beginning and end of a string.
Parameters:
Name Type Description
str string The string to be trimmed
chars string The characters to remove.
Source:
Returns:
A new string.
Type
string

type(obj) → {string}

Returns the class of a MaiaScript object.
Parameters:
Name Type Description
obj object A MaiaScript object .
Source:
Returns:
The class of a MaiaScript object.
Type
string

unshift(mtx, obj) → {array}

Removes an object from the beginning of an array.
Parameters:
Name Type Description
mtx array The array to join elements.
obj object The separator character.
Source:
Returns:
The array with the object removed.
Type
array

zero(rows, columns) → {array}

Creates a zero matrix.
Parameters:
Name Type Description
rows number Number of rows in the matrix.
columns number Number of columns in the matrix.
Source:
Returns:
A (rows x columns) matrix.
Type
array

(inner) init()

Creates the attributes of the class.
Source: