Magma JS Methods

Global Methods

Methods Description
$, $val, $value Return the variable value within the current value set.
$this Return the variable value within the current view value set.
$join Return the joined variable value referenced by a variable value within the current value set.
$group Return a map of variable values in the same group of occurrence within the current value set.
$id, $identifier Return the entity identifier within the current value set.
$var, $variable Returns the variable object at the given name.
log Provides ‘info’ level logging of messages and variable values.
now Returns the current date time wrapped in a value object.
newValue Creates a new value.
newSequence Creates a new value sequence.
$created Return the value set creation time.
$lastupdate Return the value set last update time.
source Load a javascript file.

Variable Methods

Methods Description
attribute Get the variable attribute value with the given name.
name Get the name of the variable as a Text value.
type Returns the value type of the variable, as a Text value.
entityType Returns the entity type of the variable, as a Text value.
refEntityType Returns the referenced entity type of the variable, as a Text value.
repeatable Returns if the variable is repeatable, as a Boolean value.
occurrenceGroup Returns the occurrence group of the variable, as a Text value.
mimeType Returns the mime type of the variable, as a Text value.
unit Returns the unit of the variable, as a Text value.
nature Returns the nature of the variable (CATEGORICAL, CONTINUOUS, etc.), as a Text value.
isNumeric Returns whether the variable value type is integer or decimal, as a Boolean value.
isDateTime Returns whether the variable value type is date or datetime, as a Boolean value.
isGeo Returns whether the variable value type is point, linestring or polygon, as a Boolean value.

Value Methods

Methods Description
all Returns true when the value contains all specified parameters, false otherwise.
any Returns true value when the value is equal to any of the parameter, false otherwise.
isNull Returns true if the value is null.
whenNull Returns its argument if the value is null. This method may allow avoiding an if/else block.
map Uses a lookup table to map the a value to another (which may be computed or derived).
not Returns the contrary of a boolean value or return if it does not match any of the arguments.
type Returns or changes the value’s type.
value Returns the javascript value from the value object.
length Returns the length of the value.

Value Sequence Methods

Methods Description
any Returns true value if of the provided values can be found in the value sequence.
empty Returns true value if is operating on a sequence that contains zero values.
first Returns the first value in a value sequence.
firstNotNull Returns the first not null value in a value sequence.
indexOf Returns the first position of a value in a value sequence.
last Returns the last value in a value sequence.
lastIndexOf Returns the last position of a value in a value sequence.
valueAt Returns the value at a specified index within the sequence (0-based).
size Returns the number of values within a sequence.
map Map each value in the sequence to another value.
reduce Returns the reduction of the values within a sequence.
unique Returns a sequence of distinct values.
filter Returns a sequence which values have been filtered using custom javascript predicating function.
subset Returns a subset of a sequence according to provided begin and end positions.
trimmer Returns a sequence without null values.
sort Sorts a sequence in natural order of its values or using a custom javascript comparing function.
max Returns the maximum value of a value sequence.
min Returns the minimum value of a value sequence.
avg Returns the average of a value sequence.
median Returns the median value from a value sequence.
sum Returns the sum of a value sequence.
stddev Returns the standard deviation of a value sequence.
push Adds one or more values after a value to produce a value sequence (deprecated in favor of append).
append Adds one or more values after a value to produce a value sequence.
prepend Adds one or more values before a value to produce a value sequence.
insertAt Inserts one or more values at a given position to produce a value sequence.
join Joins the text representation of the values in the sequence.
zip Returns a sequence of values, where each value is the transformation of a tuple of values, the i-th tuple contains the i-th element from each of the argument sequences.
asSequence Turns a value object into a value sequence object.
isSequence Returns whether the value is a value sequence object.

Boolean Value Methods

Methods Description
and Applies the ternary AND logic on values.
compare Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
eq Returns if left operand value is equal to right operand value.
not Returns the contrary of a boolean value or return if it does not match any of the arguments.
or Applies the ternary OR logic on values.

Numeric Value Methods

Methods Description
compare Returns a negative integer, zero, or a positive integer as the value is less than, equal to, or greater than the value argument.
eq Returns if left operand value is equal to right operand value.
ge Returns if left operand value is greater equal than right operand value.
gt Returns if left operand value is greater than right operand value.
le Returns if left operand value is lower equal than right operand value.
lt Returns if left operand value is lower than right operand value.
plus Returns result of first operand value plus second operand value.
minus Returns result of first operand value minus second operand value.
multiply Returns result of first operand value multiply second operand value.
div Returns result of first operand value divided by second operand value.
ln Returns the natural logarithm (base e) of the value.
log Returns the base-10 logarithm of the value.
abs Returns the absolute value.
pow Returns the value raised to the power of the operand.
sqroot Returns square root of the value.
cbroot Returns cubic root of the value.
root Returns arbitrary root of the value.
round Returns the rounded value.
group Group values in a ranges.

Text Value Methods

Methods Description
compare Returns a negative integer, zero, or a positive integer as the text value is less than, equal to, or greater than the text value argument.
compareNoCase Returns a negative integer, zero, or a positive integer as the text value is less than, equal to, or greater than the text value argument ignoring case.
date Returns a value of date type given a date format pattern.
datetime Returns a value of datetime type given a date time format pattern.
eq Returns if left operand value is equal to right operand value.
matches Used to match a regular expression against a string.
replace Used to find a match between a regular expression and a string, and to replace the matched substring with a new substring.
concat Returns the text type result of first operand concat second operand.
trim Returns a copy of the string, with leading and trailing whitespace omitted.
lowerCase Returns a copy of the string, lower case.
upperCase Returns a copy of the string, upper case.
capitalize Returns a copy of the string, with first character of each word capitalized.

Date and Datetime Value Methods

Methods Description
add Adds days to a value of date time type.
after Returns true if the date value is after the specified date value(s).
before Returns true if the date value is before the specified date value(s).
dayOfMonth Returns the day of month from a date as an integer starting from 1.
dayOfWeek Returns the day of week from a date as an integer starting from 1 (Sunday).
dayOfYear Returns the day of year from a date as an integer starting from 1.
format Returns the text representation of the date formatted by the provided pattern.
hour Returns the hour of the day for the 12-hour clock (0 - 11).
hourOfDay Returns the hour of the day for the 24-hour clock.
minute Returns the minute within the hour.
millisecond Returns the millisecond within the second.
month Returns the month of a date as an integer starting from 0 (January).
quarter Returns the quarter of a date as an integer starting from 0 (Q1).
second Returns the second within the minute.
semester Returns the semester of a date as an integer starting from 0 (S1).
time Returns the number of milliseconds since January 1, 1970, 00:00:00 GMT (epoch time).
weekday Returns a boolean value indicating whether the date denotes a weekday (between Monday and Friday inclusively).
weekend Returns a boolean value indicating whether the date denotes a weekend (either Sunday or Saturday).
weekOfMonth Returns the week of month from a date as an integer starting from 1.
weekOfYear Returns the week of year from a date as an integer starting from 1.
year Returns the year value.

Geo Value Methods

Methods Description
longitude Get the longitude of a point value.
latitude Get the latitude of a point value.

Measurement Unit Methods

Methods Description
unit Sets the measurement unit of the current value to the specified unit. Returns the current unit when no argument is supplied.
toUnit Measurement unit conversion: converts the current value into a different measurement unit.