Skip to content

Latest commit

 

History

History
3168 lines (2245 loc) · 82.9 KB

Operators.md

File metadata and controls

3168 lines (2245 loc) · 82.9 KB

Raport API

Operators

!= (alias is-not)


(any, any) => boolean (binary)
Returns true if the given values are not equal (not strict).
(any, schema) => boolean (binary)
(Only applies to the 'is-not' alias) Returns true if the given value does not loosely conform to the given schema.

!== (alias deep-is-not)


(any, any) => boolean (binary)
Do a deep inequality check on the first two arguments using loose equality for primitives.
(any, any, 'strict'|'loose'|'sql'|application) => boolean
Do a deep inequality check on the first two arguments using the comparison method specified by the third argument. If an application is given, it will be called with each item being checked at each step in the recursive check to determine equality.

Options

equal
What type of equality check should be used to determine whether two values are different.

The strings strict (===), loose (==), and sql (loose plus numbers, dates, and booleans have special handling when they are or are compared to strings) will use a built-in equality check.


% (alias modulus)


...any => number (binary)
Returns the modulus of the given values starting with the first.

&& (alias and)


(any, any) => any (binary)
Lazily evaluates its arguments and returns the final value or `false` if any of the values are not truthy.

* (alias multiply)


...number => number (binary)
Multiplies the given values starting with the first.

If there is context-local rounding set, it will be applied to the result (see set-defaults).

(string, number) => string (binary)
Returns the given string copied number times if the number is positive.
(any[], number) => any[] (binary)
Returns the given array concatenated number times if the array has fewer than 1,000 elements and the number is positive and less than 10,000.

** (alias pow)


...number => number (binary)
Applies exponentiation to the given arguments with right associativity.

If there is context-local rounding set, it will be applied to the result (see set-defaults).

e.g. (** 1 2 3) is 1^(2^3)

+ (alias add)


...number => number (binary)
Adds the given numbers together.

If there is context-local rounding set, it will be applied to the result (see set-defaults).

...any => string (binary)
Concatenates the given arguments as strings.
...object => object (binary)
Creates a shallow copy comprised of each given object where overlapping keys in later arguments override keys in earlier arguments.
...any[] => object (binary)
Creates a shallow copy comprised of each given array concatenated.
(date, timespan) => date (binary)
Adds the given timespan to the given date.
...timespan => timespan (binary)
Adds the given timespans together.
any => number (unary)
The unary + operator converts the given value to a number.

- (alias subtract)


...any => number (binary)
Subtracts the given values as numbers starting with the first.

If there is context-local rounding set, it will be applied to the result (see set-defaults).

(date, date) => timespan (binary)
Subtracts the second date from the first, resulting in the timespan between the two dates.
(date, timespan) => date (binary)
Subtracts the second date from the first, resulting in the timespan between the two dates.
any => number (unary)
The unary - operator converts the given value to a number and negates it.

/ (alias divide)


...any => number (binary)
Divides the given values starting with the first.

If there is context-local rounding set, it will be applied to the result (see set-defaults).


/% (alias intdiv)


...any => number (binary)
Divides the given values with integer division starting with the first.

< (alias lt)


(any, any) => boolean (binary)
Returns true if the first value is less than the second.

<= (alias lte)


(any, any) => boolean (binary)
Returns true if the first value is less than or equal to the second.

== (alias is)


(any, any) => boolean (binary)
Returns true if the given values are equal (not strict).
(any, schema) => boolean (binary)
(Only applies to the 'is' alias) Returns true if the given value loosely conforms to the given schema.

=== (alias deep-is)


(any, any) => boolean (binary)
Do a deep equality check on the first two arguments using loose equality for primitives.
(any, any, 'strict'|'loose'|'sql'|application) => boolean
Do a deep equality check on the first two arguments using the comparison method specified by the third argument. If an application is given, it will be called with each item being checked at each step in the recursive check to determine equality.

Options

equal
What type of equality check should be used to determine whether two values are different.

The strings strict (===), loose (==), and sql (loose plus numbers, dates, and booleans have special handling when they are or are compared to strings) will use a built-in equality check.


> (alias gt)


(any, any) => boolean (binary)
Returns true if the first value is greater than the second value.

>= (alias gte)


(any, any) => boolean (binary)
Returns true if the first value is greater than or equal to the second value.

??


...any => any (binary)
Returns the first non-null, non-undefined value.

abs


number => number
Returns the absolute value of the given number.

add (alias +)


...number => number (binary)
Adds the given numbers together.

If there is context-local rounding set, it will be applied to the result (see set-defaults).

...any => string (binary)
Concatenates the given arguments as strings.
...object => object (binary)
Creates a shallow copy comprised of each given object where overlapping keys in later arguments override keys in earlier arguments.
...any[] => object (binary)
Creates a shallow copy comprised of each given array concatenated.
(date, timespan) => date (binary)
Adds the given timespan to the given date.
...timespan => timespan (binary)
Adds the given timespans together.
any => number (unary)
The unary + operator converts the given value to a number.

and (alias &&)


(any, any) => any (binary)
Lazily evaluates its arguments and returns the final value or `false` if any of the values are not truthy.

array


...any => any[]
Returns all of its arguments in an array.
range => number[]
Convert a range to an array of numbers covered by the range. The maximum number of elements in the resulting array is 10,000, and the default bounds are -100 to 200.

Options

range
Use the range prototype of the operator. Without this, even a parsed range will result in an array with the range as the only element.
bounds
Sets the lower and upper bounds, respectively, of the resulting array. If the bounds are more than 10,000 apart, the lower bound will be set to 10,000 less than the upper bound.

avg


() => number (aggregate)
Computes the average of the current source.
number[] => number
Computes the average of the given array of numbers.
(any[], application) => number
Computes the average of the applications for the given array of values.
application => number (aggregate)
Computes the average of the applications for the current source.

block


...any => any
Evaluates each of its arguments and returns the value of the final argument.

case (alias switch)


(any, ...(any|application, any)) => any
Evaluates its first argument and uses it as a basis for comparison for each subsequent pair of arguments, called matchers.

The first value in a matcher is used for the comparison, and the second value is returned if the comparison holds. If the matcher first value is an application, the matcher matches if the application returns a truthy value when given the basis value. If the matcher first value is a value, the matcher matches if the first value and the basis value are loosely equal.

The basis value is available as @case or the shorthand _ in each matcher.

e.g. case 1+1 when 1 then :nope when =>4 - _ == _ then :yep else :other end
e.g. case(1+1 1 :nope =>4 - _ == _ :yep :other)

cat


...any => string
Concatenates all of the given values into a string.

ceil


number => number
Returns the given number rounded up to the nearest integer.

clamp


(number, number, number) => number
Takes a minimum, a value, and a maximum, and returns the minimum if the value is less than the minimum, the maximum if the value is more than the maximum, or the value otherwise.

coalesce


...any => any
Lazily evalutes its arguments to return the first non-nullish one it encounters.

coalesce-truth


...any => any
Lazily evalutes its arguments to return the first truthy one it encounters.

contains


(any[], any) => boolean (binary)
Returns true if the second argument is found in the first argument array using indexOf.
(any[], any[]) => boolean (binary)
Returns true if each entry in the second argument is found in the first argument array using indexOf.
(any[], application) => boolean (binary)
Returns true if the second argument application returns true for one of the values in the first argument array.
(object, application) => boolean (binary)
Returns true if the second argument application returns true for one of the [value, index, key] tuples in the first argument array.
(string, string) => boolean (binary)
Returns true if the second argument is a substring of the first argument.
(daterange, date) => boolean (binary)
Returns true if the second argument is a falls within the first argument range.

count


any[] => number
Returns the number of entries in the given array.
() => number (aggregate)
Counts the number of entries in the current source.

date


string => date
Parses the given date as a platform date (JS), using the builtin parser first and the platform parser if that fails.
(string, string) => date
Parses the given date as a platform date (JS), using the builtin parser first and the platform parser if that fails. If the second argument is parseable as a time, the date is shifted to that time.
(date, string) => date
If the second argument is parseable as a time, the given date is shifted to that time.
date => date
Processes the given date and return the result with optional named arguments applied.

Options

rel or parse
Return a raport date rather than a platform date.
shift
When combined with a relative date and time argument with a timezone, will shift the time along with the timezone in the resulting date rather than just changing the timezone and leaving the time as is.
y
Set the target year on the resulting date. This is not applicable for relative dates.
m
Set the target month on the resulting date with a 1 indexed number e.g. January is 1 rather than 0. This is not applicable for relative dates.
d
Set the target day on the resulting date. This is not applicable for relative dates.
clamp
If m or d is specified, setting a number not in the normal range will cause the date to shift outside its bounds e.g. m:13 would be January of the following year. This option will prevent that behavior.

deep-is (alias ===)


(any, any) => boolean (binary)
Do a deep equality check on the first two arguments using loose equality for primitives.
(any, any, 'strict'|'loose'|'sql'|application) => boolean
Do a deep equality check on the first two arguments using the comparison method specified by the third argument. If an application is given, it will be called with each item being checked at each step in the recursive check to determine equality.

Options

equal
What type of equality check should be used to determine whether two values are different.

The strings strict (===), loose (==), and sql (loose plus numbers, dates, and booleans have special handling when they are or are compared to strings) will use a built-in equality check.


deep-is-not (alias !==)


(any, any) => boolean (binary)
Do a deep inequality check on the first two arguments using loose equality for primitives.
(any, any, 'strict'|'loose'|'sql'|application) => boolean
Do a deep inequality check on the first two arguments using the comparison method specified by the third argument. If an application is given, it will be called with each item being checked at each step in the recursive check to determine equality.

Options

equal
What type of equality check should be used to determine whether two values are different.

The strings strict (===), loose (==), and sql (loose plus numbers, dates, and booleans have special handling when they are or are compared to strings) will use a built-in equality check.


detect-delimeters


string => CSVOptions
Detects the field, record, and quote delimiters from the first 2048 characters of the given string.
(string, number) => CSVOptions
Detects the field, record, and quote delimiters from the first given number of characters of the given string.

Options

context
Set the limit for the number of characters to examine from the given string.

diff


(any, any) => Diff
Does a deep comparison of the two arguments returning a map of deep keypath to a tuple of the left value and right value for differing paths.
(any, any, equal) => Diff
Does a deep comparison of the two arguments returning a map of deep keypath to a tuple of the left value and right value for differing paths. The third argument is used as the equality check for comparisons (see equal named argument).

Options

equal
What type of equality check should be used to determine whether two values are different. The strings strict (===), loose (==), and sql (loose plus numbers, dates, and booleans have special handling when they are or are compared to strings) will use a built-in equality check.
keys
Which keys to include in object comparisons. The default all will result in any key in either object being compared. common will result in only keys preset in both objects being compared.

divide (alias /)


...any => number (binary)
Divides the given values starting with the first.

If there is context-local rounding set, it will be applied to the result (see set-defaults).


does-not-contain


(any[], any) => boolean (binary)
Returns false if the second argument is found in the first argument array using indexOf.
(any[], any[]) => boolean (binary)
Returns false if each entry in the second argument is found in the first argument array using indexOf.
(any[], application) => boolean (binary)
Returns false if the second argument application returns true for one of the values in the first argument array.
(object, application) => boolean (binary)
Returns false if the second argument application returns true for one of the [value, index, key] tuples in the first argument array.
(string, string) => boolean (binary)
Returns false if the second argument is a substring of the first argument.
(daterange, date) => boolean (binary)
Returns false if the second argument is a falls within the first argument range.

each


(any[], application) => string
Iterates over the given array, executes the application for each value, and returns ther results joined with an empty string.
(any[], application, ...(boolean, result)) => string
Iterates over the given array, executes the application for each value, and returns ther results joined with an empty string. If the array is empty, then the final array of condition/result pairs are lazily evaluated to return one that matches.
(object, application) => string
Iterates over the given object entries, executes the application for each value, and returns ther results joined with an empty string.
(object, application, ...(boolean, result)) => string
Iterates over the given object entries, executes the application for each value, and returns ther results joined with an empty string. If the object is empty, then the final array of condition/result pairs are lazily evaluated to return one that matches.

Options

join
An alternate string to use to join the results.

eval


string => any
Evaluates the given string as an expression.

Options

template
Evaluate the given string as a template in the current context.
context
The context in which to evaluate the expression. If not given, the current context will be used.

filter


(any[], application) => any[]
Filters the given array using the given application to remove entries that return a false-y result.
(object, application) => object
Filters the given object using the given application to remove entries that return a false-y result.
(any[], application, sort[]) => any[]
Filters the given array using the given application to remove entries that return a false-y result. The result is then sorted using the given sort array.
(object, application, sort[]) => object
Filters the given object using the given application to remove entries that return a false-y result. The result is then sorted using the given sort array.
(any[], application, sort[], application|application[]) => any[]
Filters the given array using the given application to remove entries that return a false-y result. The result is then sorted using the given sort array. The result is finally grouped by the final application or array of applications.

find


(any[], application) => any
Finds the first element in the given array that matches the given application and returns it.
(object, application) => any
Finds the first value in the given object that matches the given application and returns it. The application is passed the value, index, and key of each entry.
application => any (aggregate)
Finds the first element in the current source that matches the given application and returns it.

first


any[] => any
Returns the first element in the given array.
() => any (aggregate)
Returns the first element in the current source.

flatten


any[] => any[] (aggregate)
Flattens nested arrays into a single non-nested array.
(any[], number) => any[] (aggregate)
Flattens nested arrays into a single non-nested array, up to as many levels as specified by the second argument.

Options

flat
The number of levels of nested arrays to flatten. If this is not supplied or not a number, it defaults to 1.

floor


number => number
Returns the given number rounded down to the nearest integer.

fmt (alias format)


(any, string, ...args) => string
Applies the named formatted indicated by the second argument string to the given value, passing along any additional arguments to the formatter.

format (alias fmt)


(any, string, ...args) => string
Applies the named formatted indicated by the second argument string to the given value, passing along any additional arguments to the formatter.

generate


(application) => any[]
Calls the given application, aggregating values until the application returns undefined.

If the result is an array, the elements of the array are added to the result. If the result is an object matching { value?: any, state?: any }, then the value will be added to the result and the state, if supplied, will replace the state of the generator. Any other value will be added to the result.

Each application is passed the state, last value, and index of the call. Each of the arguments is also available a special reference, @state, @last, and @index, respectively.

The global defaults for generate have a max property, defaulting to 10000, that limits the number of iterations that can be run to avoid non-terminating generators.

(range) => number[]
Iterates the members of the range and returns an array of all of the included numbers. This takes into account excluded numbers and ranges and ignores any inclusive range that includes an infinite bound.

The global defaults for generate have a max property, defaulting to 10000, that limits the number of iterations that can be run to avoid non-terminating generators.

Options

[state]
Any options passed to the operator are sent into the initial application as the state.

get


(any, string) => any
Safely retrieves the value at the given path string from the value passed as the first argument.

group


(any[], application|application[]) => any[]
Groups the given array using the given application or application array.

gt (alias >)


(any, any) => boolean (binary)
Returns true if the first value is greater than the second value.

gte (alias >=)


(any, any) => boolean (binary)
Returns true if the first value is greater than or equal to the second value.

if


(...(boolean, any)) => any
Lazily evaluates each odd argument and returns the first subsequent even argument when a truthy odd argument is found. If no truthy odd argument is found and there is not a final even argument, the final odd argument is returned.

ilike


(string, string) => any (binary)
Checks to see if the first string matches the second string used as a pattern case insensitively.
(string[], string) => any (binary)
Checks to see if any of the strings in the first argument array matches the second string used as a pattern case insensitively.
(string, string[]) => any (binary)
Checks to see if first string matches any of the second argument strings used as patterns case insensitively.
(string[], string[]) => any (binary)
Checks to see if any of the strings in the first argument array matches any of the second argument strings used as patterns case insensitively.

Options

free
Causes the patterns not to be anchored to the start and end of the target string.

in


(any, any[]) => boolean (binary)
Returns true if the first argument is found in the second argument array using indexOf.
(any[], any[]) => boolean (binary)
Returns true if each entry in the first argument is found in the second argument array using indexOf.
(application, any[]) => boolean (binary)
Returns true if the first argument application returns true for one of the values in the second argument array.
(application, object) => boolean (binary)
Returns true if the first argument application returns true for one of the [value, index, key] tuples in the second argument array.
(string, string) => boolean (binary)
Returns true if the first argument is a substring of the second argument.
(string|string[], object) => boolean (binary)
Returns true if the strings in the first argument are all keys in the given object.
(date, daterange) => boolean (binary)
Returns true if the first argument falls within the second argument range.
(number, range) => boolean (binary)
Returns true if the first argument falls within the second argument range.

index


(array, application) => object (aggregate)
Returns a map of the given array keyed on the result of the application.

If the application returns a tuple, the values in the map will be the second value in the tuple and the keys will be the first. If the key portion of the tuple is an array, the value will be set for each key in the keys array. If the application returns an empty tuple, the value in the array will be omitted from the result. The value may also be an object with a "key" or "keys" key and, optionally, a "value" key. The value may also be an object with a "many" key with an array value of multiple entries of any of the previous types to be added to the map.

Options

many
If enabled, the values in the map will be arrays aggregating all of the values with the same key. Otherwise, the last entry for a key will be the value for that key in the map.

inspect


(any) => schema
Inspects the given value and returns a schema based on its contents.

Options

mode
If set to 'schema' the result will be unparsed into a schema literal.
flat
If enabled, deeply introspect objects to include nested types in the schema.

intdiv (alias /%)


...any => number (binary)
Divides the given values with integer division starting with the first.

intersect


(any[], any[]) => any[]
Returns the intersection of the two given arrays with no duplicates.

interval


string => interval
Parses the given string as an interval.

is (alias ==)


(any, any) => boolean (binary)
Returns true if the given values are equal (not strict).
(any, schema) => boolean (binary)
(Only applies to the 'is' alias) Returns true if the given value loosely conforms to the given schema.

is-not (alias !=)


(any, any) => boolean (binary)
Returns true if the given values are not equal (not strict).
(any, schema) => boolean (binary)
(Only applies to the 'is-not' alias) Returns true if the given value does not loosely conform to the given schema.

join


(any[], string) => string
Joins all of the elements in the given array with the given string.
(any[], application, string) => string
Joins all of the results of the given application of each element in the given array with the given string.
(any[], string, string) => string
Joins all of the elements in the given array with the given string. The last element is appended using the final string if there are more than two elements.
(any[], application, string, string) => string
Joins all of the results of the given application of each element in the given array with the given string. The last element is appended using the final string if there are more than two elements.
(any[], string, string, string) => string
Joins all of the elements in the given array with the given string. The elements are joined using the final string if there are only two elements. The last element is appended using the second string if there are more than two elements.
(any[], application, string, string, string) => string
Joins all of the results of the given application of each element in the given array with the given string. The elements are joined using the final string if there are only two elements. The last element is appended using the second string if there are more than two elements.
string => string (aggregate)
Joins all of the elements in the current source with the given string.
(application, string) => string (aggregate)
Joins all of the results of the given application of each element in the current source with the given string.
(string, string) => string (aggregate)
Joins all of the elements in the current source with the given string. The last element is appended using the final string if there are more than two elements.
(application, string, string) => string (aggregate)
Joins all of the results of the given application of each element in the current source with the given string. The last element is appended using the final string if there are more than two elements.
(string, string, string) => string (aggregate)
Joins all of the elements in the current source with the given string. The elements are joined with the final string if there are only two elements. The last element is appended using the second string if there are more than two elements.
(application, string, string, string) => string (aggregate)
Joins all of the results of the given application of each element in the current source with the given string. The elements are joined with the final string if there are only two elements. The last element is appended using the second string if there are more than two elements.

keys


object => string[]
Returns an array of all of the keys in the given object.
(object, true) => string[]
Returns an array of all of the keys in the given object, including any from the prototype chain.

label-diff


(Diff, LabelMap) => Diff
Takes the given diff and label map and swaps out paths in the diff for labels in the map.

The label map is a nested object with the keys being single key paths in the diff and the values being a label or tuple of a label and label map for nested sub structures.

e.g. label-diff(d { foo:[:Company { bar::Address }] }) where d = { :foo.bar: [:street :avenue] } will result in { "Company Address": [:street :avenue] }

Options

omit
Remove any unlabelled diff entries from the output.

last


any[] => any
Returns the last element in the given array.
() => any (aggregate)
Returns the last element in the current source.

len (alias length)


string|array|dataset|object => number
Returns the length of a given string or array, the length of a given array dataset, the number of keys in a given object, or 0.

length (alias len)


string|array|dataset|object => number
Returns the length of a given string or array, the length of a given array dataset, the number of keys in a given object, or 0.

let


(string, any) => interval
Sets the local value specified by the given path in the first argument the value supplied as the second argument and returns the value that was replaced, if any.

like


(string, string) => any (binary)
Checks to see if the first string matches the second string used as a pattern case sensitively.
(string[], string) => any (binary)
Checks to see if any of the strings in the first argument array matches the second string used as a pattern case sensitively.
(string, string[]) => any (binary)
Checks to see if first string matches any of the second argument strings used as patterns case sensitively.
(string[], string[]) => any (binary)
Checks to see if any of the strings in the first argument array matches any of the second argument strings used as patterns case sensitively.

Options

free
Causes the patterns not to be anchored to the start and end of the target string.

lower


string => string
Returns the given string in lower case.

lt (alias <)


(any, any) => boolean (binary)
Returns true if the first value is less than the second.

lte (alias <=)


(any, any) => boolean (binary)
Returns true if the first value is less than or equal to the second.

map


(any[], application) => any[]
Applies the given application to each element in the given array and returns an array containing the results.
application => any[]
Applies the given application to each element in the current source and returns an array containing the results.
(object, application) => object
Applies the given application to each [value, index, key] tuple in the given object and returns an object containing the results. If the application return a null, that entry will be left out of the result. If it returns a 2-tuple with a string as the first entry, the result will replace that entry. Otherwise, the entry will have its value replaced with the result of the application.

Options

array
When truthy for an object map call, this will cause the result to be the array of application results rather than an object. The application in this case should only return result values.
entries
When truthy for an object map call, this will cause the result to be the array of resulting application entries rather than an object. The same handling for object entries still applies to this option as the operation without it.
flat
When applied to an array or an object call that results in an array, this will cause the array to be flattened up to the level specified by the value of the option. If the value is not a number but still truthy, the number defaults to 1.

max


() => number (aggregate)
Returns the largest entry in the current source.
number[] => number
Returns the largest entry in the given array of numbers.
(any[], application) => number
Returns the largest entry in the applications for the given array of values.
application => number (aggregate)
Returns the largest entry in the applications for the current source.
...number => number
Returns the largest entry in the given list of number arguments. If no arguments are given the result will be 0.

min


() => number (aggregate)
Returns the smallest entry in the current source.
number[] => number
Returns the smallest entry in the given array of numbers.
(any[], application) => number
Returns the smallest entry in the applications for the given array of values.
application => number (aggregate)
Returns the smallest entry in the applications for the current source.
...number => number
Returns the smallest entry in the given list of number arguments. If no arguments are given the result will be 0.

modulus (alias %)


...any => number (binary)
Returns the modulus of the given values starting with the first.

multiply (alias *)


...number => number (binary)
Multiplies the given values starting with the first.

If there is context-local rounding set, it will be applied to the result (see set-defaults).

(string, number) => string (binary)
Returns the given string copied number times if the number is positive.
(any[], number) => any[] (binary)
Returns the given array concatenated number times if the array has fewer than 1,000 elements and the number is positive and less than 10,000.

not


any => boolean (unary)
Negates the truthiness of the given value.

not-ilike


(string, string) => any (binary)
Checks to see if the first string does not match the second string used as a pattern case insensitively.
(string[], string) => any (binary)
Checks to see if all of the strings in the first argument array do not match the second string used as a pattern case insensitively.
(string, string[]) => any (binary)
Checks to see if first string does not match any of the second argument strings used as patterns case insensitively.
(string[], string[]) => any (binary)
Checks to see if all of the strings in the first argument array do not match any of the second argument strings used as patterns case insensitively.

Options

free
Causes the patterns not to be anchored to the start and end of the target string.

not-in


(any, any[]) => boolean (binary)
Returns false if the first argument is found in the second argument array using indexOf.
(any[], any[]) => boolean (binary)
Returns false if each entry in the first argument is found in the second argument array using indexOf.
(application, any[]) => boolean (binary)
Returns false if the first argument application returns true for one of the values in the second argument array.
(application, object) => boolean (binary)
Returns false if the first argument application returns true for one of the [value, index, key] tuples in the second argument array.
(string, string) => boolean (binary)
Returns false if the first argument is a substring of the second argument.
(string|string[], object) => boolean (binary)
Returns false if the strings in the first argument are all keys in the given object.
(date, daterange) => boolean (binary)
Returns false if the first argument falls within the second argument range.
(number, range) => boolean (binary)
Returns false if the first argument falls within the second argument range.

not-like


(string, string) => any (binary)
Checks to see if the first string does not match the second string used as a pattern case sensitively.
(string[], string) => any (binary)
Checks to see if all of the strings in the first argument array do not match the second string used as a pattern case sensitively.
(string, string[]) => any (binary)
Checks to see if first string does not match any of the second argument strings used as patterns case sensitively.
(string[], string[]) => any (binary)
Checks to see if all of the strings in the first argument array do not match any of the second argument strings used as patterns case sensitively.

Options

free
Causes the patterns not to be anchored to the start and end of the target string.

nth


(any[], number) => any
Returns the nth item in the given array using a 1-based index. If the number is negative, the offset is from the end rather than the beginning.
number => any (aggregate)
Returns the nth item in the current source using a 1-based index. If the number is negative, the offset is from the end rather than the beginning.

num


string => number
Returns the first positive number found in the string, including an optional decimal.

object


(...(string, any)) => object
Returns an object assembled from the arguments where each odd argument is a key and the subsequent even argument is its value.
e.g. object(:key1 99 :key2 73)

or (alias ||)


(any, any) => any (binary)
Lazily evaluates its arguments and returns the first truthy value or `false` if there aren't any.

overlap


(string, string, number = 0.5) => string
Returns the first overlapping substring within the two given strings that is at least the given percentage of the smallest string's length long using the similar operator.

pad


(string, number) => string
Pads the given string with spaces at both ends such that it is at least the given number of characters long.
(string, number, stringy) => string
Pads the given string with the final string at both ends such that it is at least the given number of characters long. If the final string is not a single character, a single space will be used instead.

padl


(string, number) => string
Pads the given string with spaces at the beginning such that it is at least the given number of characters long.
(string, number, stringy) => string
Pads the given string with the final string at the beginning such that it is at least the given number of characters long. If the final string is not a single character, a single space will be used instead.

padr


(string, number) => string
Pads the given string with spaces at the end such that it is at least the given number of characters long.
(string, number, stringy) => string
Pads the given string with the final string at the end such that it is at least the given number of characters long. If the final string is not a single character, a single space will be used instead.

parse


string => any
Parses the given string using the expression parser.

Options

date
Use the date parser rather than the expression parser.
template
Use the template parser rather than the expression parser.
time
Use the time parser rather than the expression parser.
schema
Use the schema parser rather than the expression parser.
base64
Use a base64 parser to decode a base64 encoded string.
xml
Use the XML parser to read data. Properties and children are equivalent. Duplicate names result in all of the duplicate values being aggregated into an array rather than last in winning.
strict
For the XML parser, be less forgiving about malformed content. Defaults to false.
csv
Use the delimited text parser rather than the expression parser.
delimited
Use the delimited text parser rather than the expression parser.
detect
If using the delimited parser, detect the delimiters and use them to parse.
header
If using the delimited parser, treat the first result as a header and use it to build objects with field names based on the header.
field
If using the delimited parser, use the given string as the field delimiter.
record
If using the delimited parser, use the given string as the record delimiter.
quote
If using the delimited parser, use the given string as the field quote.
order
If set to a falsey value, the fields in resulting objects generated from input with headers will not be keyed in alphabetical order.
fixedSize
Discard any delimited rows that are not at least as long as the header/first row.

patch


(any,...Diff) => any
Applies the given diffs to a deep copy of the given object. The direction of the patch can be changed with a named argument. By default, patches are applied in the order given using the new values of the patch to place in the result object. When run backward, the patch list is reversed, and the patches are applied in order using the old values of the patch to place in the result object.

Options

dir
If unsupplied or forward, patches are applied in given order using the new values. If backward, patches are applied in reverse order using the old values.
strict
If strict is truthy, each diff entry that is applied will ensure that the current state of the object matches the starting point of the diff before updating the object.

pipe


...any => any
This is a special built-in operator that evaluates its first argument, supplies that as an input to the next argument, supplies that result as an input to the next argument, and so on until the result of the last argument evaluation is returned. If any argument is an operation that does not reference `@pipe` or `_` as one of its arguments, then `@pipe` will be added as the first argument of that operation. Arguments that are applications are automatically applied with the piped value.

pow (alias **)


...number => number (binary)
Applies exponentiation to the given arguments with right associativity.

If there is context-local rounding set, it will be applied to the result (see set-defaults).

e.g. (** 1 2 3) is 1^(2^3)

rand (alias random)


() => number
Returns a random floating point number between 0 and 1, inclusive.
number => number
Returns a random integer between 1 and the given number, inclusive.
(number, true) => number
Returns a random floating point number between 1 and the given number, inclusive.
(number, number) => number
Returns a random integer between the given numbers, inclusive.
(number, number, true) => number
Returns a random floating point number between the given numbers, inclusive.

random (alias rand)


() => number
Returns a random floating point number between 0 and 1, inclusive.
number => number
Returns a random integer between 1 and the given number, inclusive.
(number, true) => number
Returns a random floating point number between 1 and the given number, inclusive.
(number, number) => number
Returns a random integer between the given numbers, inclusive.
(number, number, true) => number
Returns a random floating point number between the given numbers, inclusive.

reduce


(any[], application, any) => any
Folds the given array into the final argument value by passing each element in the given array into the application with the result of the last application (or the final argument for the first iteration) and returns the result of the final application.
(application, any) => any (aggregate)
Folds the current source into the final argument value by passing each element in the current source into the application with the result of the last application (or the final argument for the first iteration) and returns the result of the final application.

replace


(string, string, string) => string
Replaces the first instance of the second string found in the first string with the third string.
(string, string, string, string) => string
Replaces the first instance of a regular expression constructed with the seconds string as the expression and the fourth string as the flags, which may be empty, found in the first string with the third string.

replace-all


(string, string, string) => string
Replaces all instances of the second string found in the first string with the third string.
(string, string, string, string) => string
Replaces all instances of a regular expression constructed with the seconds string as the expression and the fourth string as the flags, which may be empty, found in the first string with the third string.

reverse


string => string
Reverses the given string.
any[] => any[]
Reverses the given array.

round


NOTE: By default, the single-number signature will round to an integer, but if the round defaults are updated to include all-numeric as true, then it will return numbers rounded to the nearest default place. Round defaults are { places:2 all-numeric:false method::half-even }.

number => number
Rounds the given number to the nearest integer.
(number, number, string) => number
Rounds the given number to the nearest decimal specified by the second number using the method specified by the string, defaulting to half-even. Supported methods are half-up, half-down, half-to-0, half-from-0, half-even, half-odd, to-0, from-0, up, and down. If the number of places negative, the number will be rounded left from the decimal point. All if the half methods look at the place to the right of the target number of places and round down if the digit is less than 5, up if the digit is more than 5, and based on the specific method if the digit is 5. For the non-half methods, if there is any amount to the right of the target place, the digit in the target place will be rounded based on specific method.

Options

places
The number of places to round to
method
The rounding method to use
string
Return the number as a string rather than a number

set


(string, any) => interval
Sets the root value specified by the given path in the first argument the value supplied as the second argument and returns the value that was replaced, if any.

set-defaults


('format', string) => any
Sets the defaults for the given named formatter. Defaults should be passed in as named options that depend on the decorator.
('round') => any
Sets the defaults for rounding operations. Defaults should be passed in as named options, which can be places, all-numeric, and method.

If a truthy option named context is supplied, the defaults will only be set in the current context and any derived from it in the future. With a context-local round default set, math operations performed in the context or its children will apply rounding as they are performed.

To clear a context-local round default, call this with truthy context and unset named options.

('generate') => any
Sets the defaults for generate operations. Defaults should be passed in as named options, which can be max. The default max is 10000.

similar


(string, string, number = 0.5, number = 2) => [string, string, number]
Finds the first similar substrings within the two given strings based on a threshhold (3rd argument, defaults to 50%) and fudge factor (4th argument, defaults to 2). The two similar substrings are returned in a tuple with the similarity percentage.

similarity


(string, string, number = 0.5, number = 2) => number
Finds the similarity percentage of the first similar substrings within the two given strings using the similar operator.

slice (alias substr)


any[] => any[]
Returns a copy of the given array.
(any[], number) => any[]
Returns a copy of the given array starting from the element at the given index.
(any[], number, number) => any[]
Returns a copy of the given array starting from the element at the given index and ending immediately before the final given index. If the final index is negative, it is an offset from the end of the array.
(string, number) => string
Returns a substring of the given string starting from the character at the given index.
(string, number, number) => any[]
Returns a substring of the given string starting from the character at the given index and ending immediately before the final given index. If the final index is negative, it is an offset from the end of the string.

sort


(any[], sort[]) => any[]
Sorts the given array using the given sort array.

Any array elements that are strings may indicate direction with a leading + or - for ascending and descending, respectively. The remainder of the string is parsed and used as an application. Any array elements that are applications are applied directly to get a comparison value. Any arguments that are objects may include a by key with an application value along with asc, desc, or dir flags. If no sorts are provided, an identity sort will be applied.

(object, sort[]) => object
Sorts the given object keys using the given sort array.

Any array elements that are strings may indicate direction with a leading + or - for ascending and descending, respectively. The remainder of the string is parsed and used as an application. Any array elements that are applications are applied directly to get a comparison value. Any arguments that are objects may include a by key with an application value along with asc, desc, or dir flags. If no sorts are provided, an identity sort will be applied to the keys.


source


any => DataSet
Creates a DataSet from the given value, or returns the value if it is already a DataSet.
(any, application) => any
Creates a DateSet from the given value if it is not already a DataSet, and then sets that as the @source to call the given application. The result of the application is returned.

split


string => string[]
Splits the given string into an array containing each of its characters.
(string, string) => string[]
Splits the given string into an array containing substrings delimited by the second argument.

strict-is


(any, any) => boolean (binary)
Returns true if the two arguments are the same literal value or are pointers to the same object.
(any, schema) => boolean (binary)
(Only applies to the 'strict-is' alias) Returns true if the given value strictly conforms to the given schema.

strict-is-not


(any, any) => boolean (binary)
Returns false if the two arguments are the same literal value or are pointers to the same object.
(any, schema) => boolean (binary)
(Only applies to the 'strict-is-not' alias) Returns true if the given value does not strictly conform to the given schema.

string


any => string
Politely stringifies the given value, meaning that there are no undefined, null, or object prototype values strings returned.

Options

json
Forces the output string to be JSON.
raport
Forces the output string to be a raport expresion. This can be paired with any options to the stringify function supplied by raport.
string
Processes the value as a styled string.

substr (alias slice)


any[] => any[]
Returns a copy of the given array.
(any[], number) => any[]
Returns a copy of the given array starting from the element at the given index.
(any[], number, number) => any[]
Returns a copy of the given array starting from the element at the given index and ending immediately before the final given index. If the final index is negative, it is an offset from the end of the array.
(string, number) => string
Returns a substring of the given string starting from the character at the given index.
(string, number, number) => any[]
Returns a substring of the given string starting from the character at the given index and ending immediately before the final given index. If the final index is negative, it is an offset from the end of the string.

subtract (alias -)


...any => number (binary)
Subtracts the given values as numbers starting with the first.

If there is context-local rounding set, it will be applied to the result (see set-defaults).

(date, date) => timespan (binary)
Subtracts the second date from the first, resulting in the timespan between the two dates.
(date, timespan) => date (binary)
Subtracts the second date from the first, resulting in the timespan between the two dates.
any => number (unary)
The unary - operator converts the given value to a number and negates it.

sum


() => number (aggregate)
Computes the sum of the current source.
number[] => number
Computes the sum of the given array of numbers.
(any[], application) => number
Computes the sum of the applications for the given array of values.
application => number (aggregate)
Computes the sum of the applications for the current source.

switch (alias case)


(any, ...(any|application, any)) => any
Evaluates its first argument and uses it as a basis for comparison for each subsequent pair of arguments, called matchers.

The first value in a matcher is used for the comparison, and the second value is returned if the comparison holds. If the matcher first value is an application, the matcher matches if the application returns a truthy value when given the basis value. If the matcher first value is a value, the matcher matches if the first value and the basis value are loosely equal.

The basis value is available as @case or the shorthand _ in each matcher.

e.g. case 1+1 when 1 then :nope when =>4 - _ == _ then :yep else :other end
e.g. case(1+1 1 :nope =>4 - _ == _ :yep :other)

time-span (alias time-span-ms)


NOTE: If there's no way to get an accurate result from the given timespan e.g. you want years or months from a span specified in ms, approximations will be used. The approximations are 365.25 days in a year and 30.45 days in a month.

number => number[]
Returns an array of time units based on options given that represent the number of milliseconds passed as the first argument.
(date, date) => number[]
Returns an array of time units based on options given that represent the distance between the two dates.
timespan => number[]
Returns an array of time units based on options given that represent the distance between the start and end of the given timespan.

Options

unit
The units desired in the result. This can be either a string or array of strings with the units represented by [y]ears, [M|mo]nths, [w]eeks, [d]ays, [h]ours, [m|mm]inutes, [s]econds, [ms] where 'M' will get months and 'mm' or 'm' not followed by an 'o' will get minutes. The string form can only be used for unambiguous single character units. Units must be specified in descending order by size.
string
Causes the output to be a string rather than an array.
round
Determines how the results should be rounded. By default they are 'floor'ed, but this can also be 'ceil' or 'round'. Rounding is done based on the next largest available unit after the smallest requiested unit e.g. hours if days are requested last or months if years are the only requested unit.

time-span-ms (alias time-span)


NOTE: If there's no way to get an accurate result from the given timespan e.g. you want years or months from a span specified in ms, approximations will be used. The approximations are 365.25 days in a year and 30.45 days in a month.

number => number[]
Returns an array of time units based on options given that represent the number of milliseconds passed as the first argument.
(date, date) => number[]
Returns an array of time units based on options given that represent the distance between the two dates.
timespan => number[]
Returns an array of time units based on options given that represent the distance between the start and end of the given timespan.

Options

unit
The units desired in the result. This can be either a string or array of strings with the units represented by [y]ears, [M|mo]nths, [w]eeks, [d]ays, [h]ours, [m|mm]inutes, [s]econds, [ms] where 'M' will get months and 'mm' or 'm' not followed by an 'o' will get minutes. The string form can only be used for unambiguous single character units. Units must be specified in descending order by size.
string
Causes the output to be a string rather than an array.
round
Determines how the results should be rounded. By default they are 'floor'ed, but this can also be 'ceil' or 'round'. Rounding is done based on the next largest available unit after the smallest requiested unit e.g. hours if days are requested last or months if years are the only requested unit.

trim


string => string
Trims whitespace from both ends of the given string.

triml


string => string
Trims whitespace from the beginning of the given string.

trimr


string => string
Trims whitespace from the end of the given string.

unique


any[] => any[]
Returns a copy of the given array with no duplicate elements.
() => any[] (aggregate)
Returns a copy of the current source with no duplicate elements.
(any[], application) => any[]
Returns a copy of the given array with no duplicate application results.
application => any[] (aggregate)
Returns a copy of the current source with no duplicate application results.

unique-map


(any[], application) => any[]
Returns an array of application results from the given array with no duplicate elements.
application => any[] (aggregate)
Returns an array of application results of the current source with no duplicate elements.

unless


(...(boolean, any)) => any
Lazily evaluates each odd argument and returns the first subsequent even argument when a false-y odd argument is found. If no false-y odd argument is found and there is not a final even argument, the final odd argument is returned.

unparse


any => string
Stringifies the given value as a raport expression.

upper


string => string
Converts the given string to upper case.

valid


(any, schema) => boolean
Returns true if the given value validates against the given schema.

Options

strict
Validate in strict mode rather than the default loose mode.
mode
Sets the mode of validation e.g. strict or loose or missing.

validate


NOTE: The schema of an error is @[{ error: string; type?: 'strict'; path?: string; actual?: string; expected?: string; value?: any }]. If the error is the result of a strict check, the type will be set to 'strict'. The path is the keypath from the root of the given value to the piece of data that caused the error. Missing mode requires that any referenced named types be declared. Strict mode additionally requires that there be no unspecified properties in objects and tuples.

(any, schema) => true|error[]
Returns true if the given value validates against the given schema or an array of errors if it does not.

Options

strict
Validate in strict mode rather than the default loose mode.
mode
Sets the mode of validation e.g. strict or loose or missing.

values


object => any[]
Returns an array of all of the values in the given object.

with


(object, application) => any
Evaluates the given application with the given value as the context, returning the result of the application.
(object, application, any) => any
Evaluates the given application with the given value as the context, returning the result of the application. If the value is false-y, the final argument is returned instead.

wrap-count


string,number?,font?
Calculates the number of lines that the given string will occupy in the given width in rem using the given font. If the width is not specified, the @widget.width or @placement.availableX will be used. If the font is not specified, the @widget.font will be used. Inherited fonts are not considered.

Options

width
A named version of the second positional argument.
font
A named version of the third positional argument. This is an object with the relevant parts of the interface conforming to { family?:string, size?:number, line?:number, metric?: number }. family defaults to "sans", size defaults to 0.83, line defaults to size, and metric defaults to the constant pixel width of the font at 16px per em e.g. sans: 7.4, serif: 6.7, mono: 7.85, and narrow: 5.9.
family
Overrides the given font family.
size
Overrides the given font size.
line
Overrides the given font line height.
metric
Overrides the given font metric.
break-word
Determines whether words that exceed the width should be broken, defaulting to true.

|| (alias or)


(any, any) => any (binary)
Lazily evaluates its arguments and returns the first truthy value or `false` if there aren't any.

Formats

[operator]


Calls the named operator as a formatter, passing the target value as the first argument with any arguments to the formatter following. Any set defaults for the formatter are passed as options to the operator.


base


Converts the given number to the given base

Options

base - number

The target base e.g. 2 or 8 or 16.


base64


Converts the given value to a base64 encoded string.


case


Change the casing of the value.

Options

case - 'upper'|'lower'|'snake'|'kebab'|'pascal'|'camel'|'proper'

The case format to use.


date


Formats the value as a date string using placeholder characters, where repeated characters render more descriptive or padded values. Any non-placeholder characters are rendered as entered. The default format is yyyy-MM-dd. Placeholders can be escaped with a \ if the placeholder needs to be included in the output. Available placeholders are:

  • y - year
  • M - month
  • d - date
  • E - day of week
  • H - hour (24 hour)
  • h or k - hour (12 hour)
  • m - minute
  • s - second
  • S - millisecond
  • a - AM/PM
  • z - timezone offset

Options

format - string

The format template to apply.


dollar


Formats the value as a dollar amount with two decimal places by default.

Options

dec - number

The number of decimal places to render.

group - string

The string to use as a grouping divider.

sign - string

The currency symbol to render.

neg - 'sign'|'wrap'|'both'

How to display negative values. Sign shows a leading minus symbol. Wrap wraps the value in parenteses.


hex


Formats the given number in hexadecimal, or if the value is not a number, encodes it as string in hexadecimal.


int (alias integer)


Formats the value as an integer.

Options

group - string

The string to use as a grouping divider.

neg - 'sign'|'wrap'|'both'

How to display negative values. Sign shows a leading minus symbol. Wrap wraps the value in parenteses.


integer (alias int)


Formats the value as an integer.

Options

group - string

The string to use as a grouping divider.

neg - 'sign'|'wrap'|'both'

How to display negative values. Sign shows a leading minus symbol. Wrap wraps the value in parenteses.


iso8601


Formats the value as an ISO-8601 timestamp.


noxml


Escapes special XML characters so that the value may be safely rendered into xml.


num (alias number)


Formats the value as an number.

Options

dec - number

The number of decimal places to render.

group - string

The string to use as a grouping divider.

neg - 'sign'|'wrap'|'both'

How to display negative values. Sign shows a leading minus symbol. Wrap wraps the value in parenteses.


number (alias num)


Formats the value as an number.

Options

dec - number

The number of decimal places to render.

group - string

The string to use as a grouping divider.

neg - 'sign'|'wrap'|'both'

How to display negative values. Sign shows a leading minus symbol. Wrap wraps the value in parenteses.


ordinal


Render the value as an ordinal number.

Options

group - string

The string to use as a grouping divider.


phone


Formats the value as phone number e.g. 111-2222, (111) 222-3333, 1-888-777-6666


styled


Processes the value as a styled string.


time


Formats a date value as a time string using placeholder characters, where repeated characters render more descriptive or padded values. Any non-placeholder characters are rendered as entered. The default format is HH:mm:ss. Available placeholders are:

  • y - year
  • M - month
  • d - date
  • E - day of week
  • H - hour (24 hour)
  • h or k - hour (12 hour)
  • m - minute
  • s - second
  • S - millisecond
  • a - AM/PM
  • z - timezone offset

Options

format - string

The format template to apply.


timestamp


Formats a date value as a timestamp using placeholder characters, where repeated characters render more descriptive or padded values. Any non-placeholder characters are rendered as entered. The default format is yyyy-MM-dd HH:mm:ss. Available placeholders are:

  • y - year
  • M - month
  • d - date
  • E - day of week
  • H - hour (24 hour)
  • h or k - hour (12 hour)
  • m - minute
  • s - second
  • S - millisecond
  • a - AM/PM
  • z - timezone offset

Options

format - string

The format template to apply.


timestamptz


Formats a date value as a timestamp with timezone offset using placeholder characters, where repeated characters render more descriptive or padded values. Any non-placeholder characters are rendered as entered. The default format is yyyy-MM-dd HH:mm:sszzz. Available placeholders are:

  • y - year
  • M - month
  • d - date
  • E - day of week
  • H - hour (24 hour)
  • h or k - hour (12 hour)
  • m - minute
  • s - second
  • S - millisecond
  • a - AM/PM
  • z - timezone offset

Options

format - string

The format template to apply.


xml


Converts the given value to XML if possible.

Options

indent - number

Indent each successive set of child nodes with this number of spaces.