# Taxi StdLib

> Reference documentation on functions provided in Taxi's StdLib packages

Source: https://taxilang.org/docs/language/stdlib-summary

The Taxi Standard Library provides a collection of built-in functions for common operations
including string manipulation, date handling, math, collections, and more.

## Strings

A collection of functions for manipulating strings

| Function | Description |
|----------|-------------|
| [`applyFormat`](https://taxilang.org/docs/language/stdlib/applyFormat) | `applyFormat(input: Any, format: String):String`  Applies a format string to the input value using [Java Formatter](https://docs.oracle.com/javase/8/docs/api/java/util... |
| [`concat`](https://taxilang.org/docs/language/stdlib/concat) | `concat(Any...):String`  Joins all provided values into a single string, in the order they are passed. |
| [`containsPattern`](https://taxilang.org/docs/language/stdlib/containsPattern) | `containsPattern(source: String, regex: String): Boolean`  Returns `true` if any part of the source string matches the provided regular expression. |
| [`containsString`](https://taxilang.org/docs/language/stdlib/containsString) | `containsString(source:String, valueToSearchFor:String):Boolean`  Returns `true` if `source` contains `valueToSearchFor` as a substring. |
| [`endsWith`](https://taxilang.org/docs/language/stdlib/endsWith) | `endsWith(source: String, valueToSearchFor:String):Boolean`  Returns `true` if `source` ends with the specified suffix. |
| [`indexOf`](https://taxilang.org/docs/language/stdlib/indexOf) | `indexOf(source:String, valueToSearchFor:String):Int`  Returns the zero-based index of `valueToSearchFor` within `source`, or `-1` if not found. |
| [`left`](https://taxilang.org/docs/language/stdlib/left) | `left(source:String, count:Int):String`  Returns the leftmost `count` characters from a string. |
| [`length`](https://taxilang.org/docs/language/stdlib/length) | `length(String):Int`  Returns the number of characters in the string. |
| [`lowerCase`](https://taxilang.org/docs/language/stdlib/lowerCase) | `lowerCase(String):String`  Converts all characters in the string to lower case. |
| [`matches`](https://taxilang.org/docs/language/stdlib/matches) | `matches(source: String, regex: String): Boolean`  Returns `true` if the **entire** source string matches the provided regular expression. |
| [`mid`](https://taxilang.org/docs/language/stdlib/mid) | `mid(source: String, startIndex: Int, endIndex: Int):String`  Returns the middle of a string, starting at `startIndex` (inclusive) and ending just before `endIndex` (exclusive). |
| [`padEnd`](https://taxilang.org/docs/language/stdlib/padEnd) | `padEnd(input: String, length: Int, padWith: String):String`  Pads the string to the specified total `length` by appending `padWith` characters at the end. |
| [`padStart`](https://taxilang.org/docs/language/stdlib/padStart) | `padStart(input: String, length: Int, padWith: String):String`  Pads the string to the specified total `length` by prepending `padWith` characters at the start. |
| [`replace`](https://taxilang.org/docs/language/stdlib/replace) | `replace(source: String, searchValue:String, replacement: String):String`  Replaces all occurrences of `searchValue` in `source` with `replacement`, returning a new string. |
| [`right`](https://taxilang.org/docs/language/stdlib/right) | `right(source:String, count:Int):String`  Returns the rightmost `count` characters from a string. |
| [`startsWith`](https://taxilang.org/docs/language/stdlib/startsWith) | `startsWith(source: String, valueToSearchFor:String):Boolean`  Returns `true` if `source` begins with the specified prefix. |
| [`trim`](https://taxilang.org/docs/language/stdlib/trim) | `trim(String):String`  Removes leading and trailing whitespace from a string. |
| [`upperCase`](https://taxilang.org/docs/language/stdlib/upperCase) | `upperCase(String):String`  Converts all characters in the string to upper case. |
## Collections

A collection of functions for operating on collections

| Function | Description |
|----------|-------------|
| [`all`](https://taxilang.org/docs/language/stdlib/all) | `<T> all(collection: T[], predicate: (T) -> Boolean): Boolean`  Returns `true` if every item in the collection satisfies the predicate, or `false` if any item does not. |
| [`allOf`](https://taxilang.org/docs/language/stdlib/allOf) | `allOf(values:Boolean...): Boolean`  Returns `true` only if all provided boolean values are `true`. |
| [`any`](https://taxilang.org/docs/language/stdlib/any) | `<T> any(collection: T[], predicate: (T) -> Boolean): Boolean`  Returns `true` if at least one item in the collection satisfies the predicate, or `false` if none do. |
| [`anyOf`](https://taxilang.org/docs/language/stdlib/anyOf) | `anyOf(values:Boolean...): Boolean`  Returns `true` if at least one of the provided boolean values is `true`. |
| [`append`](https://taxilang.org/docs/language/stdlib/append) | `<T> append(array1: T[], array2: T[]):T[]`  Returns a new collection containing the elements of the first array followed by the elements of the second array. |
| [`collectAllInstances`](https://taxilang.org/docs/language/stdlib/collectAllInstances) | `<T> collectAllInstances(collection: lang.taxi.Type<T>): T`  Collects and merges all instances of a type from the current data context, bypassing ambiguity checks. |
| [`contains`](https://taxilang.org/docs/language/stdlib/contains) | `<T> contains(collection: T[], searchTarget:T): Boolean`  Returns `true` if the collection contains the specified search target element. |
| [`containsAll`](https://taxilang.org/docs/language/stdlib/containsAll) | `<T> containsAll(collection: T[], searchTarget:T[]): Boolean`  Returns `true` if the collection contains every element in the search targets array. |
| [`containsAny`](https://taxilang.org/docs/language/stdlib/containsAny) | `<T> containsAny(collection: T[], searchTarget:T[]): Boolean`  Returns `true` if the collection contains at least one of the specified search targets. |
| [`exactlyOne`](https://taxilang.org/docs/language/stdlib/exactlyOne) | `<T> exactlyOne(collection:T[]):T`  Returns the only item from the provided collection, or throws an error if there isn't exactly one item in the collect... |
| [`filter`](https://taxilang.org/docs/language/stdlib/filter) | `<T> filter(collection:T[], callback: (T) -> Boolean):T[]`  Returns a new collection containing only the members of the original collection that match the provided predicate. |
| [`filterEach`](https://taxilang.org/docs/language/stdlib/filterEach) | `<T> filterEach(item: T, callback: (T) -> Boolean):T?`  Evaluates the predicate against the provided item, returning the item if the predicate returns true, or null otherwise. |
| [`first`](https://taxilang.org/docs/language/stdlib/first) | `<T> first(collection: T[]):T`  Returns the first item within the collection. |
| [`getAtIndex`](https://taxilang.org/docs/language/stdlib/getAtIndex) | `<T> getAtIndex(collection: T[], index: Int):T`  Returns the item at the provided index in the collection. |
| [`ifEmpty`](https://taxilang.org/docs/language/stdlib/ifEmpty) | `<T> ifEmpty(source:T[], defaultValue:T[]): T[]`  Returns the source array if it is non-empty, otherwise returns the provided default array. |
| [`indexOfItem`](https://taxilang.org/docs/language/stdlib/indexOfItem) | `<T> indexOfItem(collection:T[], searchItem: T):Int`  Returns the zero-based index of an item within a collection, or `-1` if the item was not found. |
| [`intersection`](https://taxilang.org/docs/language/stdlib/intersection) | `<T> intersection(collectionA: T[], collectionB: T[]):T[]`  Returns a new collection containing only the elements that are present in both of the provided collections. |
| [`isNullOrEmpty`](https://taxilang.org/docs/language/stdlib/isNullOrEmpty) | `<T> isNullOrEmpty(collection:T[]):Boolean`  Returns `true` if the provided collection is either `null` or contains zero elements. |
| [`joinToString`](https://taxilang.org/docs/language/stdlib/joinToString) | `<T> joinToString(values:T[], separator: String = ",", prefix: String? = null, postfix: String? = null): String`  Creates a string from all the elements separated using `separator` and using the given `prefix` and `postfix` if supp... |
| [`last`](https://taxilang.org/docs/language/stdlib/last) | `<T> last(collection: T[]):T`  Returns the last item within the collection. |
| [`listOf`](https://taxilang.org/docs/language/stdlib/listOf) | `<T> listOf(values:T...):T[]`  Creates and returns an array containing all the provided values. |
| [`none`](https://taxilang.org/docs/language/stdlib/none) | `<T> none(collection: T[], predicate: (T) -> Boolean): Boolean`  Returns `true` if none of the items in the collection satisfy the predicate. |
| [`noneOf`](https://taxilang.org/docs/language/stdlib/noneOf) | `noneOf(values:Boolean...): Boolean`  Returns `true` only if all provided boolean values are `false`. |
| [`orEmpty`](https://taxilang.org/docs/language/stdlib/orEmpty) | `<T> orEmpty(source:T[]): T[]`  Returns the source array unchanged if it is non-null, or an empty array if it is `null`. |
| [`single`](https://taxilang.org/docs/language/stdlib/single) | `<T> single(collection:T[], callback: (T) -> Boolean):T`  Returns the first item from a collection that matches the provided predicate. |
| [`singleBy`](https://taxilang.org/docs/language/stdlib/singleBy) | `<T,A> singleBy(collection:T[], groupingFunction: (T) -> A, searchValue: A):T`  Returns the item from a collection where the value returned by the grouping function matches the search value. |
| [`size`](https://taxilang.org/docs/language/stdlib/size) | `<T> size(collection:T[]):Int`  Returns the number of elements in the collection. |
## Dates

Mess about with time. Flux capacitor not included

| Function | Description |
|----------|-------------|
| [`addDays`](https://taxilang.org/docs/language/stdlib/addDays) | `<T> addDays(T, Int):T`  Adds the specified number of days to a date, datetime, or instant. |
| [`addMinutes`](https://taxilang.org/docs/language/stdlib/addMinutes) | `<T> addMinutes(T, Int):T`  Adds the specified number of minutes to a datetime or instant. |
| [`addSeconds`](https://taxilang.org/docs/language/stdlib/addSeconds) | `<T> addSeconds(T, Int):T`  Adds the specified number of seconds to a datetime or instant. |
| [`currentDate`](https://taxilang.org/docs/language/stdlib/currentDate) | `currentDate():Date`  Returns the current local date (no time component). |
| [`currentDateTime`](https://taxilang.org/docs/language/stdlib/currentDateTime) | `currentDateTime():DateTime`  Returns the current local date and time. |
| [`currentTime`](https://taxilang.org/docs/language/stdlib/currentTime) | `currentTime():Time`  Returns the current local time (no date component). |
| [`now`](https://taxilang.org/docs/language/stdlib/now) | `now():Instant`  Returns the current UTC instant. |
| [`parseDate`](https://taxilang.org/docs/language/stdlib/parseDate) | `<T> parseDate(String):T`  Parses a string into a date, datetime, or instant value. |
## Math

Numbers 'n' such. Maths for the brits.

| Function | Description |
|----------|-------------|
| [`average`](https://taxilang.org/docs/language/stdlib/average) | `average(values: Any[]):Decimal`  Returns the arithmetic mean of a collection of numeric values. |
| [`max`](https://taxilang.org/docs/language/stdlib/max) | `<T,A> max(collection: T[], callback: (T) -> A):A`  Returns the maximum value in the collection, computed by applying the selector function to each element. |
| [`min`](https://taxilang.org/docs/language/stdlib/min) | `<T,A> min(collection: T[], callback: (T) -> A):A`  Returns the minimum value in the collection, computed by applying the selector function to each element. |
| [`round`](https://taxilang.org/docs/language/stdlib/round) | `round(value: Decimal, precision: Int = 0): Decimal`  Rounds a decimal value to the specified number of decimal places. |
| [`sum`](https://taxilang.org/docs/language/stdlib/sum) | `<T,A> sum(collection: T[], callback: (T) -> A):A`  Returns the sum of values in the collection, computed by applying the selector function to each element. |
## Objects

Utilities for dealing with equality, etc

| Function | Description |
|----------|-------------|
| [`emptyInstance`](https://taxilang.org/docs/language/stdlib/emptyInstance) | `<A> emptyInstance(instanceType:lang.taxi.Type<A>): A`  Returns an instance of the requested type with all fields set to their empty state: scalars are `null`, collections a... |
| [`equals`](https://taxilang.org/docs/language/stdlib/equals) | `<A,B> equals(a:A, b:B): Boolean`  Returns `true` if two values are equal. |
## Enums

Utilities for enums

| Function | Description |
|----------|-------------|
| [`enumForName`](https://taxilang.org/docs/language/stdlib/enumForName) | `<T> enumForName(enumType: lang.taxi.Type<T>, enumName: String): T`  Returns the enum member matching the provided value string. |
| [`hasEnumNamed`](https://taxilang.org/docs/language/stdlib/hasEnumNamed) | `<T> hasEnumNamed(enumType: lang.taxi.Type<T>, enumName: String): Boolean`  Returns `true` if the enum has an explicitly declared member matching the provided name. |
## Aggregations

Functions for aggregating data within transformations.

| Function | Description |
|----------|-------------|
| [`sumOver`](https://taxilang.org/docs/language/stdlib/sumOver) | `declare query function sumOver(Any...):Decimal`  A Vyne-specific aggregate function used in analytical queries to compute a running or grouped sum. |
## Functional

Functions that are functionally functions. Funky

| Function | Description |
|----------|-------------|
| [`fold`](https://taxilang.org/docs/language/stdlib/fold) | `<T,A> fold(collection: T[], initial: A, callback: (T,A) -> A):A`  Iterates over a collection, combining elements with an accumulator to produce a single result. |
| [`map`](https://taxilang.org/docs/language/stdlib/map) | `<T,A> map(collection: T[], callback: (T) -> A):A[]`  Applies a transformation function to every element in a collection, returning a new array of the results. |
| [`reduce`](https://taxilang.org/docs/language/stdlib/reduce) | `<T,A> reduce(collection: T[], callback: (T,A) -> A):A`  Reduces a collection to a single value by applying a combining function to each element and the accumulated result. |
## Transformations

Functions for converting between types

| Function | Description |
|----------|-------------|
| [`convert`](https://taxilang.org/docs/language/stdlib/convert) | `<T> convert(source: Any, targetType: lang.taxi.Type<T>): T`  Converts a source value to the target type using only the data already available — no service calls are made. |
| [`toRawType`](https://taxilang.org/docs/language/stdlib/toRawType) | `toRawType(source: Any):Any`  Removes the semantic typing from a scalar value, returning it typed as its raw primitive. |
## Parsing

Functions for converting between types

| Function | Description |
|----------|-------------|
| [`parseJson`](https://taxilang.org/docs/language/stdlib/parseJson) | `<T> parseJson(source: String, type: Type<T>):T`  Parses a JSON string into the specified type. |
## Errors

Functions for creating and handling errors

| Function | Description |
|----------|-------------|
| [`throw`](https://taxilang.org/docs/language/stdlib/throw) | `throw(error:Any):Nothing`  Throws an error, halting execution. |
