Standard Library

The standard library is built into the runtime — no imports needed. Here's the complete reference.

Built-in Functions

FunctionDescriptionExample
print(...)Output values to stdout, space-separatedprint("hello", 42)
str(val)Convert any value to stringstr(42) → "42"
len(val)Length of string, list, or objectlen("hi") → 2
time()Current Unix timestamp (float seconds)t = time()
sleep(ms)Pause execution (returns Promise)await sleep(1000)
fetch(url)HTTP GET (returns Promise, async)body = await fetch(url)
spawn(fn, ...)Spawn a function on the event loopp = spawn("fun", 1, 2)

String Methods

MethodResultDescription
.len()numberLength of the string
.upper()stringUppercase conversion
.lower()stringLowercase conversion
.trim()stringTrim leading/trailing whitespace
.starts_with(s)boolCheck prefix
.ends_with(s)boolCheck suffix
.contains(s)boolCheck substring
.replace(from, to)stringReplace all occurrences
.split(delim)listSplit into list of strings
.repeat(n)stringRepeat n times
.slice(start, end)stringExtract substring
.index_of(s)numberFirst occurrence position (or -1)
.to_number()numberParse as float (0 on failure)
.is_empty()boolCheck if empty string
.chars()listSplit into character list

Number Methods

MethodResultDescription
.to_string()stringFormat as string
.ceil()numberRound up
.floor()numberRound down
.round()numberRound to nearest integer
.abs()numberAbsolute value
.sqrt()numberSquare root
.pow(n)numberRaise to power n
.is_integer()boolCheck if integer value
.to_int()numberTruncate fractional part

Object Methods

MethodResultDescription
.keys()listList of field names
.values()listList of field values
.entries()listList of [key, value] pairs
.has(key)boolCheck if field exists
.len()numberNumber of fields

List Methods

MethodResultDescription
.map(fn)listTransform each element
.filter(fn)listKeep elements matching predicate
.reduce(init, fn)anyAccumulate left-to-right
.each(fn)selfSide-effect iteration
.find(fn)anyFirst matching element
.some(fn)boolAny element matches?
.every(fn)boolAll elements match?
.includes(val)boolValue in list?
.index_of(val)numberFind position (or -1)
.sorted()listNumeric sort
.reversed()listReverse order
.slice(start, end)listExtract sublist
.concat(list)listAppend another list
.flatten()listFlatten one level
.take(n)listFirst n elements
.drop(n)listDrop first n elements
.unique()listRemove adjacent duplicates

Operators

OperatorDescription
+ - * / %Arithmetic (+ coerces numbers to strings)
+= -= *= /= %=Compound assignment
== != < <= > >=Comparison
and / or / notBoolean logic (short-circuit)
..Range literal
.Field access / method call
orFailure fallback
except { ... }Failure pattern matching