This document details the standard library functions available in EZ.
out valuePrints a value to the standard output followed by a newline. (Note: keyword-stmt, not function call)
str(value) -> StringConverts any value to its string representation.
num(value) -> NumberConverts a string or boolean to a number. Returns 0 if conversion fails.
type(value) -> StringReturns the type of the value: "nil", "boolean", "number", "string", "array", "dictionary", "function", "class", "instance", "future".
len(collection) -> NumberReturns the length of a string, array, or dictionary.
clock() -> NumberReturns the processor time consumed by the program in milliseconds.
stop(milliseconds)Pauses execution of the current thread for the specified duration.
floor(n), ceil(n)Rounds a number down or up.
abs(n)Returns the absolute value.
sqrt(n), pow(base, exp)Square root and exponentiation.
rand(), randint(min, max)Random number generation. rand() returns 0.0-1.0.
upper(s), lower(s)Converts case.
trim(s)Removes whitespace from both ends.
replace(s, old, new)Replaces all occurrences of old with new.
split(s, delimiter) -> ArraySplits string into an array.
slice(s, start, end) -> StringReturns a substring.
push(array, value)Adds an element to the end of an array.
pop(array) -> ValueRemoves and returns the last element of an array.
keys(dict) -> ArrayReturns all keys in a dictionary.
values(dict) -> ArrayReturns all values in a dictionary.
spawn(function, args...) -> FutureStarts a function in a new thread. Returns a Future object.
await(future) -> ValueWaits for a Future to complete and returns its result. Alias: sync(future).
fetch(url, [options]) -> FutureInitiates an HTTP request.
url: Stringoptions: Dictionary (optional)
method: “GET” or “POST”body: Request body stringheaders: Dictionary of headersserver(port, handler)Starts a simple HTTP server (Windows implementation).
handler: A callback function |request| that returns a response string.db_open(path)Opens a connection to a valid SQLite database file.
db_query(sql) -> ArrayExecutes a SELECT query and returns rows as an array of dictionaries.
db_execute(sql)Executes a command (INSERT, UPDATE, DELETE).
db_close()Closes the database connection.