All functions
The full standard library — 51 functions, every one with a typed signature the compiler enforces (TF2007 for unknown names, TF2008 for wrong arguments). This index is generated from the same definitions the compiler and the runtime use, so it cannot drift. Need more? Bring your own functions.
string(value: unknown): stringConverts any value to its string representation (JSON for objects and arrays).
length(value: string): numberNumber of characters in the string.
contains(value: string, substring: string): booleanTrue if the string contains the given substring.
matches(value: string, pattern: string): booleanTrue if the string matches the regular expression `pattern`.
upper(value: string): stringUppercases the string.
lower(value: string): stringLowercases the string.
trim(value: string): stringRemoves leading and trailing whitespace.
pad(value: string, width: number, char?: string): stringPads to `width` with `char` (default space); a negative width pads on the left.
substring(value: string, start: number, length?: number): stringExtracts `length` characters from `start`; a negative start counts from the end.
split(value: string, separator: string, limit?: number): string[]Splits on a separator, optionally keeping only the first `limit` parts.
replace(value: string, pattern: string, replacement: string): stringReplaces every occurrence of `pattern` with `replacement`.
base64encode(value: string): stringEncodes the string to Base64 (UTF-8 safe).
base64decode(value: string): stringDecodes a Base64 string (UTF-8 safe).
encodeUrl(value: string): stringEncodes a full URL (`encodeURI`).
decodeUrl(value: string): stringDecodes a full URL (`decodeURI`).
encodeUrlComponent(value: string): stringEncodes a URL component (`encodeURIComponent`).
decodeUrlComponent(value: string): stringDecodes a URL component (`decodeURIComponent`).
number(value: string | number | boolean): numberParses strings and booleans into a number (`undefined` if not parseable).
formatBase(value: number, radix?: number): stringRenders an integer in the given radix (2–36, default 10).
floor(value: number): numberRounds down to the nearest integer.
ceil(value: number): numberRounds up to the nearest integer.
round(value: number, precision?: number): numberRounds to `precision` digits, half-to-even like JSONata.
abs(value: number): numberAbsolute value.
power(base: number, exponent: number): number`base` raised to `exponent`.
sqrt(value: number): numberSquare root (`undefined` for negative input).
random(): numberPseudo-random number in [0, 1).
sum(items: number[]): numberSum of the numbers (0 for an empty array).
max(items: number[]): numberLargest number (`undefined` for an empty array).
min(items: number[]): numberSmallest number (`undefined` for an empty array).
average(items: number[]): numberArithmetic mean (`undefined` for an empty array).
boolean(value: unknown): booleanJSONata truthiness: `""`, `0`, `[]` and `{}` are false.
not(value: unknown): booleanNegated JSONata truthiness.
exists(value: unknown): booleanTrue unless the value is `undefined` (`null` exists).
count(items: unknown[]): numberNumber of elements.
join(items: string[], separator?: string): stringConcatenates the strings with a separator (default `""`).
append(first: unknown[], second: unknown[]): unknown[]Concatenates two arrays.
zip(first: unknown[], second: unknown[]): unknown[][]Pairs elements by index, truncated to the shorter array.
sort(items: string[] | number[]): string[] | number[]Sorts in natural ascending order; the result keeps the input type.
reverse(items: unknown[]): unknown[]Reverses the order; the result keeps the input type.
shuffle(items: unknown[]): unknown[]Random permutation; keeps the input type.
distinct(items: unknown[]): unknown[]Removes duplicates (deep equality for objects); keeps the input type.
keys(value: object): string[]Property names (merged across elements for an array of objects).
values(value: object): unknown[]Property values, typed as the union of the object's field types.
lookup(value: object, key: string): unknownValue of the given key (mapped over an array of objects).
merge(objects: object[]): objectMerges an array of objects left to right.
spread(value: object): object[]Splits an object into an array of single-property objects.
type(value: unknown): string`"string" | "number" | "boolean" | "null" | "array" | "object" | "undefined"`.
now(): stringCurrent timestamp, ISO 8601.
millis(): numberCurrent timestamp, milliseconds since the epoch.
fromMillis(millis: number): stringEpoch milliseconds → ISO 8601 string.
toMillis(timestamp: string): numberISO 8601 (or any parseable date) string → epoch milliseconds.