Functions
String
Lower Words
lowerWords(string)
Convert all words in a string to lowercase.
Example
lowerWords("Hello, World!")
// output: "hello, world!"
Dot Case
dotCase(string)
Convert a string to dot.case.
Example
dotCase("Hello, World!")
// output: "hello.world"
Kebab Case
kebabCase(string)
Convert a string to kebab-case.
Example
kebabCase("Hello, World!")
// output: "hello-world"
Length
len(value)
Get the length of a string, list, or map.
Example
len("hello")
// output: 5
Explode
explode([separator], string)
Explode a string into a list of substrings. It's the same as split() with the arguments reversed.
Example
explode(", ", "a, b, c")
// output: ["a", "b", "c"]
Char
char(string)
Convert an ASCII code to a character.
Example
char(65)
// output: "A"
Join
join(list, separator)
Join a list of strings into a single string with a separator.
Example
join(["a", "b", "c"], ", ")
// output: "a, b, c"
Snake Case
snakeCase(string)
Convert a string to snake_case.
Example
snakeCase("Hello, World!")
// output: "hello_world"
Lower
lower(string)
Convert a string to lowercase.
Example
lower("HELLO")
// output: "hello"
Split
split(string, [separator])
Split a string into a list of substrings.
Example
split("a, b, c", ", ")
// output: ["a", "b", "c"]
Type
type(value)
Get the type of a value as a string.
Example
type(42)
// output: "int"
Upper
upper(string)
Convert a string to uppercase.
Example
upper("hello")
// output: "HELLO"
Up First
upFirst(string)
Convert the first character of a string to uppercase.
Example
upFirst("hello")
// output: "Hello"
Pascal Case
pascalCase(string)
Convert a string to PascalCase.
Example
pascalCase("Hello, World!")
// output: "HelloWorld"
Up Words
upWords(string)
Convert all words in a string to uppercase.
Example
upWords("hello, world!")
// output: "Hello, World!"
Rune
rune(str)
Convert a 1-character string to an ASCII code.
Example
rune("A")
// output: 65
Lower First
lowerFirst(string)
Convert the first character of a string to lowercase.
Example
lowerFirst("Hello")
// output: "hello"
Camel Case
camelCase(string)
Convert a string to camelCase.
Example
camelCase("Hello, World!")
// output: "helloWorld"
Find
find(haystack, needle)
Find the first occurrence of a substring in a string or a value in a list.
Example
find("hello", "e")
// output: 1
System
Time
time(none)
Get the current date and time as a string.
Example
time()
// output: "2018-01-01 12
Args
args(none)
Get the command-line arguments passed to the script.
Example
args()
// output: ["arg1", "arg2"]
Echo
echo(value1, value2, ...)
Print values to the standard output.
Example
echo("hello", 42)
// output: hello 42
Exit
exit([code])
Exit the script with an optional exit code.
Example
exit(1)
// output: exit status 1
Read
read([filename])
Read the contents of a file or standard input.
Example
read("file.txt")
// output: "contents of file.txt"
Conversion
Str
str(value)
Convert a value to a string.
Example
str([1, 2, 3])
// output: "[1, 2, 3]"
Int
int(value)
Convert a value to an integer.
Example
int("42")
// output: 42
Array
Slice
slice(str or list, start, end)
Get a substring or sublist from a string or list.
Example
slice("hello", 1, 3)
// output: "el"
Sort
sort(list, [key])
Sort a list of values.
Example
sort([3, 1, 2])
// output: [1, 2, 3]
Range
range(n)
Generate a list of integers from 0 to n-1.
Example
range(3)
// output: [0, 1, 2]
Append
append(list, value1, value2, ...)
Append values to a array.
Example
append([1, 2], 3, 4)
// output: [1, 2, 3, 4]
File System
File Get Contents
fileGetContents(url)
Get the contents of a file or URL.
Example
fileGetContents("http
// output: "..."
HTTP
HTTP Listen
httpListen(portOrAddress)
Start the HTTP server.
Example
httpListen("
// output: Server is starting on http
HTTP Register
httpRegister(pattern, handler)
Register a handler function for a URL pattern.
Example
httpRegister("/", func() { return "Hello, World!" })
// output: "Hello, World!"