API Reference
Complete reference for all built-in funcs in Flowa.
Type funcs
| func | Description | Example |
|---|---|---|
type(x) | Get type of value | type(42) → "number" |
len(x) | Get length | len("hello") → 5 |
tonumber(s) | Convert to number | tonumber("42") → 42 |
tostring(x) | Convert to string | tostring(42) → "42" |
String funcs
| func | Description | Example |
|---|---|---|
upper(s) | Convert to uppercase | upper("hello") → "HELLO" |
lower(s) | Convert to lowercase | lower("WORLD") → "world" |
substring(s, start, end) | Extract substring | substring("hello", 0, 3) → "hel" |
contains(s, substr) | Check if contains | contains("hello", "ell") → true |
trim(s) | Remove whitespace | trim(" hi ") → "hi" |
replace(s, old, new) | Replace text | replace("hi", "i", "o") → "ho" |
split(s, delim) | Split into array | split("a,b,c", ",") → ["a","b","c"] |
startsWith(s, p) | Check prefix | startsWith("abc", "a") → true |
endsWith(s, suf) | Check suffix | endsWith("abc", "c") → true |
charAt(s, i) | Get char at index | charAt("abc", 0) → "a" |
Math funcs
| func | Description | Example |
|---|---|---|
sqrt(x) | Square root | sqrt(16) → 4 |
power(x, y) | Exponentiation | power(2, 8) → 256 |
floor(x) | Round down | floor(3.7) → 3 |
ceil(x) | Round up | ceil(3.2) → 4 |
round(x) | Round nearest | round(3.5) → 4 |
abs(x) | Absolute value | abs(-5) → 5 |
min(a, b) | Minimum | min(10, 5) → 5 |
max(a, b) | Maximum | max(10, 5) → 10 |
Array funcs
| func | Description | Example |
|---|---|---|
push(arr, x) | Add to end | push([1,2], 3) → [1,2,3] |
pop(arr) | Remove last | pop([1,2,3]) → 3 |
shift(arr) | Remove first | shift([1,2,3]) → 1 |
reverse(arr) | Reverse | reverse([1,2,3]) → [3,2,1] |
sort(arr) | Sort | sort([3,1,2]) → [1,2,3] |
slice(arr, start, end) | Extract portion | slice([1,2,3,4], 1, 3) → [2,3] |
includes(arr, x) | Check contains | includes([1,2,3], 2) → true |
indexOf(arr, x) | Find index | indexOf([1,2,3], 2) → 1 |
join(arr, sep) | Join array | join(["a","b"], ",") → "a,b" |
I/O funcs
| func | Description |
|---|
System Functions
| Function | Purpose |
|---|---|
exit(code) | Terminate program |
sleep(ms) | Sleep for milliseconds |
random() | Random number (0-100) |
print(s) | Print to stdout |
Error Handling (Result)
| Function | Purpose |
|---|---|
Ok(val) | Create success result |
Err(val) | Create error result |
isOk(res) | Check if success |
isErr(res) | Check if error |
unwrap(res) | Get value or panic |
File System Module (fs)
| func | Description |
|---|---|
fs.readFile(path) | Read file contents |
fs.writeFile(path, content) | Write to file |
fs.appendFile(path, content) | Append to file |
fs.exists(path) | Check if file exists |
JSON Module
| func | Description |
|---|---|
json.stringify(obj) | Convert to JSON string |
json.parse(str) | Parse JSON string |
Authentication Module (auth)
| func | Description |
|---|---|
auth.hash(password) | Hash password with bcrypt |
auth.verify(password, hash) | Verify password |
JWT Module
| func | Description |
|---|---|
jwt.sign(payload) | Create JWT token |
jwt.verify(token) | Verify token validity |
jwt.decode(token) | Decode token payload |
Email Module (mail)
| func | Description |
|---|---|
mail.send(to, subject, body) | Send email via SMTP |
SQLite Module
| func | Description |
|---|---|
sqlite.open(path) | Open/create database |
sqlite.exec(db, sql) | Execute SQL statement |
sqlite.query(db, sql) | Execute SELECT query |
sqlite.close(db) | Close database |
HTTP Module
| func | Description |
|---|---|
http.createServer() | Create HTTP server |
server.on(method, path, handler) | Add route handler |
server.listen(port) | Start listening |
http.get(url) | Make GET request |
http.post(url, data) | Make POST request |
Cron Module
| func | Description |
|---|---|
cron.schedule(expr, fn) | Schedule periodic task |
Logging Module
| func | Description |
|---|---|
log.info(msg) | Info level log |
log.warn(msg) | Warning level log |
log.error(msg) | Error level log |
log.debug(msg) | Debug level log |
OS Module
| func | Description |
|---|
| os.exec(cmd) | Execute shell command |
| os.cwd() | Get current directory |
| os.chdir(path) | Change directory |
| os.platform() | Get platform name |
| os.arch() | Get architecture |
Environment Variables
Access via env object:
let value = env.VARIABLE_NAME;
let api_key = env.API_KEY;Operators
Arithmetic
+Addition-Subtraction*Multiplication/Division%Modulo
Comparison
==Equal!=Not equal<Less than<=Less than or equal>Greater than>=Greater than or equal
Logical
&&Logical AND||Logical OR!Logical NOT
Keywords
Reserved keywords:
let, func, if, else, while, for, return,
true, false, null, break, continueNext Steps
- Examples - See funcs in action
- Language Guide - Learn the language
- GitHub (opens in a new tab) - Source code