Jyro Standard Library Reference
A complete reference of all built-in functions available in the Jyro scripting language.
Immutability: Jyro follows an immutable-by-default design. Functions return new values rather than modifying their inputs in place. Arguments to standard library functions are never altered.
Chaining: Functions that return arrays, strings, or objects can be chained by nesting calls or using the result as input to another function. Functions that return scalars (numbers, booleans) or null are terminal and cannot be meaningfully chained.
Array functions
| Function | Description | Mutates | Chainable |
|---|---|---|---|
| Append | Adds an element to the end of an array | No, returns new array | Yes |
| Concatenate | Joins two arrays into a single new array | No, returns new array | Yes |
| Distinct | Removes duplicate elements, keeping first occurrence | No, returns new array | Yes |
| First | Returns the first element, or null if empty | No | No |
| Flatten | Recursively flattens nested arrays into a single level | No, returns new array | Yes |
| FlattenOnce | Flattens nested arrays by one level only | No, returns new array | Yes |
| GroupBy | Groups array elements by a field value into an object | No, returns new object | Yes (object) |
| IndexOf | Returns the position of a value in an array or string | No | No |
| Insert | Inserts an element at a specified index | No, returns new array | Yes |
| Last | Returns the last element, or null if empty | No | No |
| Length | Returns the length of a string, array, or object | No | No |
| Prepend | Adds an element to the beginning of an array | No, returns new array | Yes |
| RandomChoice | Selects a random element from an array | No | No |
| Range | Generates an array of numbers in a range with optional step | No, returns new array | Yes |
| RemoveAt | Removes the element at a specified index | No, returns new array | Yes |
| RemoveFirst | Removes the first element from an array | No, returns new array | Yes |
| RemoveLast | Removes the last element from an array | No, returns new array | Yes |
| Reverse | Reverses the order of elements | No, returns new array | Yes |
| SelectMany | Flattens a nested array field from each object | No, returns new array | Yes |
| Skip | Skips the first N elements | No, returns new array | Yes |
| Slice | Extracts a portion of an array by index range | No, returns new array | Yes |
| Sort | Sorts elements by type group then value | No, returns new array | Yes |
| SortByField | Sorts objects by a field in ascending or descending order | No, returns new array | Yes |
DateTime functions
| Function | Description | Mutates | Chainable |
|---|---|---|---|
| DateAdd | Adds a time amount to a date | No, returns new string | No |
| DateDiff | Calculates the difference between two dates in a given unit | No | No |
| DatePart | Extracts a component from a date (year, month, day, etc.) | No | No |
| FormatDate | Formats a date using a .NET format pattern | No, returns new string | No |
| Now | Returns the current UTC date and time in ISO 8601 | No | No |
| ParseDate | Parses a date string and normalizes to ISO 8601 | No, returns new string | No |
| Today | Returns the current UTC date without time | No | No |
Lambda functions
Higher-order functions that accept inline lambda expressions as arguments.
| Function | Description | Mutates | Chainable |
|---|---|---|---|
| All | Tests whether all elements satisfy a predicate | No | No |
| Find | Returns the first element matching a predicate | No | No |
| Each | Executes a lambda for each element (side effects only) | No, returns null | No |
| Map | Transforms each element using a lambda | No, returns new array | Yes |
| Reduce | Accumulates an array into a single value | No | No |
| Any | Tests whether any element satisfies a predicate | No | No |
| SortBy | Sorts an array using a lambda key extractor | No, returns new array | Yes |
| Where | Filters an array using a lambda predicate | No, returns new array | Yes |
Math functions
| Function | Description | Mutates | Chainable |
|---|---|---|---|
| Absolute | Returns the absolute value of a number | No | No |
| Average | Returns the arithmetic mean of numeric values | No | No |
| Ceiling | Rounds up to the nearest integer | No | No |
| Clamp | Constrains a number to a min/max range | No | No |
| Floor | Rounds down to the nearest integer | No | No |
| Log | Returns the logarithm with an optional base | No | No |
| Max | Returns the largest numeric value in an array | No | No |
| Median | Returns the median value of a numeric array | No | No |
| Min | Returns the smallest numeric value in an array | No | No |
| Mode | Returns the most frequently occurring value | No | No |
| Power | Raises a number to a specified power | No | No |
| RandomInt | Generates a cryptographically secure random integer | No | No |
| Round | Rounds a number to a specified precision with configurable tie-breaking | No | No |
| SquareRoot | Returns the square root of a number | No | No |
| Sum | Returns the sum of all numeric values in an array | No | No |
Query functions
Field-based query functions for filtering and projecting arrays of objects.
| Function | Description | Mutates | Chainable |
|---|---|---|---|
| AllByField | Tests whether all objects match a field condition | No | No |
| AnyByField | Tests whether any object matches a field condition | No | No |
| CountIf | Counts objects matching a field condition | No | No |
| WhereByField | Returns objects matching a field condition | No, returns new array | Yes |
| FindByField | Returns the first object matching a field condition | No | No |
| Omit | Removes specified fields from each object | No, returns new array | Yes |
| Project | Extracts specified fields from each object | No, returns new array | Yes |
| Select | Extracts a single field value from each object | No, returns new array | Yes |
Schema functions
| Function | Description | Mutates | Chainable |
|---|---|---|---|
| ValidateRequired | Checks that an object contains required non-null fields | No | No |
| ValidateSchema | Validates data against a JSON Schema, returning errors | No, returns new array | Yes |
String functions
| Function | Description | Mutates | Chainable |
|---|---|---|---|
| Contains | Tests whether a string contains a substring (or array contains element) | No | No |
| EndsWith | Tests whether a string ends with a suffix | No | No |
| Join | Joins array elements into a string with a separator | No, returns new string | Yes (string) |
| ToLower | Converts a string to lowercase | No, returns new string | Yes (string) |
| PadLeft | Pads a string on the left to a specified width | No, returns new string | Yes (string) |
| PadRight | Pads a string on the right to a specified width | No, returns new string | Yes (string) |
| RandomString | Generates a cryptographically secure random string | No, returns new string | Yes (string) |
| RegexMatch | Returns the first regex match | No | No |
| RegexMatchAll | Returns all regex matches as an array | No, returns new array | Yes |
| RegexMatchDetail | Returns a detailed match object with capture groups | No, returns new object | Yes (object) |
| RegexTest | Tests whether a string matches a regex pattern | No | No |
| Replace | Replaces all occurrences of a substring | No, returns new string | Yes (string) |
| Split | Splits a string into an array using a delimiter | No, returns new array | Yes (array) |
| StartsWith | Tests whether a string begins with a prefix | No | No |
| Substring | Extracts a portion of a string by position and optional length | No, returns new string | Yes (string) |
| ToNumber | Converts a string to a number (returns null on failure) | No | No |
| ToUpper | Converts a string to uppercase | No, returns new string | Yes (string) |
| Trim | Removes leading and trailing whitespace | No, returns new string | Yes (string) |
Utility functions
| Function | Description | Mutates | Chainable |
|---|---|---|---|
| Base64Decode | Decodes a Base64 string to UTF-8 | No, returns new string | Yes (string) |
| Base64Encode | Encodes a string to Base64 | No, returns new string | Yes (string) |
| Clone | Creates a deep copy of a value | No, returns new value | Yes |
| Diff | Compares two objects and returns a structured summary of their differences | No, returns new object | Yes (object) |
| Coalesce | Returns the first non-null value from an array | No | Depends on result type |
| FromJson | Parses a JSON string into a Jyro value | No, returns new value | Depends on result type |
| HasProperty | Tests whether an object has a property (even if null) | No | No |
| Keys | Returns all property names as an array | No, returns new array | Yes (array) |
| Merge | Merges multiple objects into a new object | No, returns new object | Yes (object) |
| NewGuid | Generates a new UUID v4 string | No | No |
| ToBoolean | Converts a value to boolean using Jyro truthiness rules | No | No |
| ToJson | Converts a Jyro value to a JSON string | No, returns new string | Yes (string) |
| ToString | Converts a value to its string representation | No, returns new string | Yes (string) |
| TypeOf | Returns the type name as a string | No | No |
| Values | Returns all property values as an array | No, returns new array | Yes (array) |
| Sleep | Pauses script execution for the specified number of milliseconds | No | No |