RADS Logo

๐Ÿ“š Standard Library

Complete reference for built-in modules and functions

Built-in Functions

FunctionDescriptionExample
echo(value)Print to stdoutecho("Hello")
to_string(value)Convert to stringto_string(42)
to_int(value)Convert to integerto_int("123")
to_float(value)Convert to floatto_float("3.14")

Module: net

Networking and HTTP functionality.

Functions

  • http_server(host, port) - Create HTTP server
  • route(server, path, handler) - Register route
  • static(server, prefix, dir) - Serve static files
  • serve(server) - Start server
  • http_get(url) - HTTP GET request
  • http_post(url, body) - HTTP POST request
  • json_response(json) - Create JSON response

Module: io

File I/O and stream processing.

Functions

  • read_file(path) - Read entire file
  • write_file(path, content) - Write to file
  • open(path, mode) - Open file stream
  • close(stream) - Close stream
  • read_line(stream) - Read line from stream

Module: media

Audio and image processing.

Functions

  • load_audio(path) - Load audio file
  • load_image(path) - Load image file
  • convert(output, format, bitrate) - Convert audio
  • resize(width, height) - Resize image
  • apply_filter(name) - Apply image filter

Module: datetime ๐Ÿ•

Date and time handling for real-world applications.

Functions

FunctionDescriptionExample
datetime.now()Current timestamp as structdatetime.now().year
datetime.format(ts, fmt)Format timestamp to stringdatetime.format(now, "YYYY-MM-DD")
datetime.parse(str, fmt)Parse string to timestampdatetime.parse("2025-03-01", "YYYY-MM-DD")
datetime.unix(ts)Get Unix timestampdatetime.unix(now)
datetime.from_unix(unix)Create from Unix timestampdatetime.from_unix(1772373508)
datetime.add(ts, days, hrs, min, sec)Add time to timestampdatetime.add(now, 1)
datetime.diff(ts1, ts2)Time difference in secondsdatetime.diff(tomorrow, now)
datetime.weekday(ts)Day of week (0=Sunday)datetime.weekday(now)

Timestamp Struct Fields

  • .year - Year (2025)
  • .month - Month (1-12)
  • .day - Day (1-31)
  • .hour - Hour (0-23)
  • .minute - Minute (0-59)
  • .second - Second (0-59)
  • .unix - Unix timestamp

Module: regex ๐Ÿ”

Pattern matching and text manipulation using POSIX regex.

Functions

FunctionDescriptionExample
regex.compile(pattern)Compile regex pattern (cached)regex.compile("\\d+")
regex.match(regex, str)Boolean match checkregex.match(p, "123")
regex.findall(regex, str)Find all matchesregex.findall(p, "a1b2")
regex.search(regex, str)First match with positionregex.search(p, "price: 99")
regex.replace(regex, str, repl)Replace matchesregex.replace(p, "a1", "X")
regex.split(regex, str)Split by patternregex.split(p, "a,b;c")
regex.groups(regex, str)Extract capture groupsregex.groups("(\\d+)", "abc123")

Module: test ๐Ÿงช

Built-in testing framework with familiar assertions.

Test Structure

import test;

test.describe("My tests", blast() {
    test.it("should work", blast() {
        test.expect(1 + 1).toBe(2);
    });
});

test.run();

Assertion Functions

FunctionDescription
test.describe(name, fn)Define test suite
test.it(name, fn)Define test case
test.expect(val).toBe(expected)Strict equality
test.expect(val).toEqual(expected)Deep equality
test.expect(val).toBeTruthy()Truthy check
test.expect(val).toBeFalsy()Falsy check
test.expect(val).toBeNull()Null check
test.expect(val).toBeGreaterThan(n)Greater than
test.expect(val).toBeLessThan(n)Less than
test.beforeEach(fn)Setup before each test
test.afterEach(fn)Cleanup after each test
test.run()Execute all tests
test.skip(name, fn)Skip a test

Module: env ๐ŸŒ

Environment variable access and system information.

Functions

FunctionDescriptionExample
env.get(name)Get environment variableenv.get("HOME")
env.set(name, value)Set environment variableenv.set("DEBUG", "1")
env.has(name)Check if variable existsenv.has("PATH")
env.unset(name)Remove environment variableenv.unset("DEBUG")
env.list()Get all variables as structenv.list()
env.paths()Parse PATH into arrayenv.paths()
env.home()Get HOME directoryenv.home()
env.cwd()Get current working directoryenv.cwd()
env.user()Get current usernameenv.user()
env.shell()Get current shellenv.shell()

Module: cli ๐Ÿ–ฅ๏ธ

Command-line argument parsing for CLI tools.

Functions

FunctionDescriptionExample
cli.args()Get raw argument arraycli.args()
cli.program()Get program namecli.program()
cli.count()Get argument countcli.count()
cli.has_flag(name)Check if flag presentcli.has_flag("--verbose")
cli.flag(name)Get flag valuecli.flag("--output")
cli.flags()Get all flags as structcli.flags()
cli.args_after_flag(name)Get args after flagcli.args_after_flag("--")
cli.parse(spec)Parse with specificationcli.parse(spec)

Module: csv ๐Ÿ“Š

CSV file parsing and generation for data processing.

Functions

FunctionDescriptionExample
csv.parse(str)Parse CSV string to arraycsv.parse(data)
csv.stringify(data)Convert array to CSV stringcsv.stringify(rows)
csv.read(path)Read CSV filecsv.read("data.csv")
csv.write(path, data)Write CSV filecsv.write("out.csv", rows)

Module: base64 ๐Ÿ”

Base64 encoding and decoding for data encoding.

Functions

FunctionDescriptionExample
base64.encode(str)Encode string to base64base64.encode("hello")
base64.decode(str)Decode base64 to stringbase64.decode("aGVsbG8=")
base64.encode_bytes(arr)Encode byte arraybase64.encode_bytes(bytes)
base64.decode_bytes(str)Decode to byte arraybase64.decode_bytes(enc)

Other Built-ins

FunctionDescription web_init()Initialize web engine js_eval(code)Execute JavaScript js_evalFile(path)Run JS file html_parse(html)Parse HTML html_querySelector(doc, selector)Query DOM css_parse(css)Parse CSS pkg_load(name)Load plugin pkg_list()List plugins