lang
Language primitives: string, number, bytes, array, and boolean helpers for data manipulation. Requires load lang (import the helpers you use, e.g. load lang [@map @filter], or qualify them as @lang:map).
load langHelpers
Section titled “Helpers”| Helper | Returns | Description |
|---|---|---|
| @lang:all | bool | Return true if every element satisfies the predicate. |
| @lang:any | bool | Return true if at least one element satisfies the predicate. |
| @lang:at | any | Access an element by index in an array. |
| @lang:bytes.at | bytes | Access a single byte by index in a bytes value. |
| @lang:bytes.concat | bytes | Concatenate bytes values together. |
| @lang:bytes.len | number | Return the byte length of a bytes value. |
| @lang:bytes.not | bytes | Bitwise NOT of a bytes value (256-bit complement). |
| @lang:bytes.slice | bytes | Extract a byte range from a bytes value. |
| @lang:concat | array | Concatenate arrays together. |
| @lang:enumerate | array | Return an array of [index, element] pairs. |
| @lang:filter | array | Keep elements of an array for which a helper returns truthy. |
| @lang:find | any | Return the first element that satisfies the predicate. |
| @lang:flat | array | Flatten one level of nesting in an array. |
| @lang:includes | bool | Check whether an array contains an element. |
| @lang:len | number | Return the length of an array. |
| @lang:map | array | Transform each element of an array by applying a helper. |
| @lang:num.format | string | Format a number with decimal places (like formatUnits). |
| @lang:num.parse | number | Parse a decimal string with a given number of decimals (like parseUnits). |
| @lang:reduce | any | Reduce an array to a single value by applying a helper. |
| @lang:reverse | array | Return a new array with elements in reverse order. |
| @lang:slice | array | Extract a section of an array. |
| @lang:sort | array | Sort an array using a comparator helper. |
| @lang:str.at | string | Access a character by index in a string. |
| @lang:str.concat | string | Concatenate strings together. |
| @lang:str.includes | bool | Check whether a string contains a substring. |
| @lang:str.join | string | Join array elements into a string with a delimiter. |
| @lang:str.len | number | Return the length of a string. |
| @lang:str.lower | string | Convert a string to lowercase. |
| @lang:str.replace | string | Replace all occurrences of a substring. |
| @lang:str.slice | string | Extract a section of a string. |
| @lang:str.split | array | Split a string by a delimiter into an array of strings. |
| @lang:str.upper | string | Convert a string to uppercase. |
| @lang:unique | array | Remove duplicates from an array, preserving first-occurrence order. |
| @lang:unzip | array | Transpose an array of pairs into two separate arrays. |
| @lang:zip | array | Combine two arrays element-wise into an array of pairs. |