On this page

Standard Library

Zena includes an expanding standard library. The goal is for the standard library to be fairly extensive, so that there are standard ways of performing common tasks without requiring third-party dependencies, and to give the Zena ecosystem common patterns, utilities, and data types to build upon.

WARNING

The standard library is in active development and is currently being reorganized. Library structure, naming, and APIs are experimental and subject to change.

See these GitHub issues for major upcoming changes:

Libraries

Library Description
zena:args Command-line argument parsing with flags, options, positional arguments, subcommands, and help text generation.
zena:assert Test and runtime assertions for validating values and error conditions.
zena:async Asynchronous programming primitives: futures, completers, structured concurrency with task groups, cancellation scopes, and microtask scheduling.
zena:bench Statistical benchmark runner for comparing execution performance across code variants.
zena:bigint Arbitrary-precision signed integers (`BigInt`).
zena:cli Command-line interface support over WASI 0.3, for the component target: arguments, environment variables, the working directory and process exit, over `wasi:cli@0.3.0` as the compiler synthesizes it from the vendored WIT.
zena:collections Collection data structures: maps, sets, and array types.
zena:console Standard output and error logging utilities.
zena:core Foundational language types and utilities: strings, errors, options, results, boxes, ranges, arrays, iterators, and byte buffers.
zena:crypto Cryptography: SHA-256, HMAC-SHA256, HKDF-SHA256, and ECDSA on P-256 and secp256k1. Pure Zena.
zena:encoding Binary-to-text encodings, and a check for UTF-8.
zena:extensions Loading components as extensions, for programs the `zena` command's host runs: `zena-cli:host/extensions` as the compiler synthesizes it from the host's WIT. An extension is a long-lived instance this program calls through objects, and which calls this program through objects this program made for it; the host forwards the calls as typed values. The host grants it with `--allow-extensions` (or `ZENA_ALLOW_EXTENSIONS=1`), apart from spawning; anywhere else the imports are stubs that trap.
zena:fetch HTTP client for making network requests.
zena:fs File system access over WASI 0.3, for the component target.
zena:glob Pattern matching and regular expression translation for glob patterns.
zena:host-setup What a program on the `zena` command's host needs installed before it runs, for the `zena-cli` target: `Error`'s stack traces, from `zena-cli:host/stack-trace` as the compiler synthesizes it from the host's WIT, installed into `zena:core` through the hooks in `core/error/stack-hooked.zena`.
zena:http HTTP server and middleware library for Zena.
zena:json JSON serialization, deserialization, and AST representation.
zena:math Mathematical operations, numeric limits, bit manipulation intrinsics, and wide arithmetic.
zena:memory Low-level access to WebAssembly linear memory and memory allocators.
zena:path File path manipulation and inspection for forward-slash delimited paths.
zena:process Spawning host processes, for programs the `zena` command's host runs: `zena-cli:host/process` as the compiler synthesizes it from the host's WIT. The host grants it to the command and to `zena-run --allow-spawn`; anywhere else the imports are stubs that trap.
zena:random Random numbers from the host's cryptographically secure generator: `wasi:random`'s `random` interface on the component targets, and `crypto.getRandomValues` on js.
zena:regex Regular expression parsing, matching, and text replacement.
zena:signals Signals: values that track which computations read them, and bring those computations up to date when they change.
zena:simd WebAssembly 128-bit fixed-width SIMD vector types and instructions.
zena:stream Asynchronous data streaming between producers and consumers.
zena:task Composable combinators for deferred asynchronous operations.
zena:test Test framework for structuring and running test suites.
zena:time Monotonic time measurement, durations, and timers.
zena:url URL parsing, resolution, percent-encoding, and URL pattern matching.
zena:wasi Low-level WebAssembly Component Model and WASI runtime integration.
zena:wasm Running other Wasm programs, for programs the `zena` command's host runs: `zena-cli:host/wasm` as the compiler synthesizes it from the host's WIT. The test runner runs each compiled test this way. The host grants it together with process spawning; anywhere else the imports are stubs that trap.
zena:web-elements 57 declarations
zena:web-templates 21 declarations