Standard Library
txiki.js ships a small standard library of modules that build on the core runtime. They are imported using the tjs: scheme:
import assert from 'tjs:assert';
import { parse } from 'tjs:path';
import { Database } from 'tjs:sqlite';
assert.eq(1 + 1, 2);
Modules
| Module | Description |
|---|---|
tjs:assert | Assertion functions for testing |
tjs:ffi | Foreign Function Interface for calling native libraries |
tjs:getopts | Command-line argument parsing |
tjs:hashing | Cryptographic hash functions (guide) |
tjs:ipaddr | IP address parsing and manipulation |
tjs:path | File path utilities (POSIX and Windows) |
tjs:posix-socket | Low-level POSIX socket API |
tjs:readline | Interactive line editing and ANSI colors |
tjs:sqlite | SQLite3 database |
tjs:utils | Utility functions for formatting and inspecting values |
tjs:uuid | UUID generation and validation |
tjs:wasi | WebAssembly System Interface |
See the API Reference for the full per-symbol documentation.
Build-time feature gating
A couple of modules depend on optional build features and may be absent from a custom build:
tjs:sqliterequiresBUILD_WITH_SQLITE(on by default). When disabled, importing it throws andlocalStoragefalls back to an in-memory store.tjs:wasi(and theWebAssemblyglobal) requiresBUILD_WITH_WASM(on by default). When disabled, importing it throws a module-not-found error.
Detect availability at runtime via tjs.engine.features:
if (tjs.engine.features.sqlite) {
const { Database } = await import('tjs:sqlite');
// ...
}