Standard library / os · on the one-page reference

os

Stable — almost the entire namespace is two raw Linux syscalls (uname() covers type/release/ version/machine/hostname in one call; sysinfo() covers uptime/loadavg/ totalmem/freemem in one call), no libc.

A practical subset of Node's os module. All called as functions, not read as properties, the same deviation as path.sep()/process.platform(). os.platform()/os.arch() duplicate process.platform()/process.arch() intentionally — Node itself defines both independently with identical values.

os.platform()

→ string — same as process.platform().

console.log(os.platform()); // linux
os.arch()

→ string — same as process.arch().

console.log(os.arch()); // x64
os.type() Wasm: limited

→ string — the kernel name, via uname(2).

console.log(os.type()); // Linux
os.release() Wasm: limited

→ string — the kernel release string.

console.log(os.release());
os.version() Wasm: limited

→ string

console.log(os.version());
os.machine() Wasm: limited

→ string

console.log(os.machine()); // x86_64
os.hostname() Wasm: limited

→ string

console.log(os.hostname());
os.endianness()

→ string — "LE" or "BE".

console.log(os.endianness()); // LE
os.tmpdir()

→ string — checks TMPDIR, TMP, TEMP, falls back to "/tmp".

console.log(os.tmpdir());
os.homedir()

→ string — the HOME environment variable. Deviation from Node: Node falls back to a passwd-database lookup when HOME is unset; Lumen returns "" instead, rather than introduce the compiler's first libc dependency for one rarely-hit fallback path.

console.log(os.homedir());
os.uptime() Wasm: limited

→ int — system uptime in seconds.

console.log(os.uptime() > 0); // true
os.totalmem() Experimental Wasm: limited

→ int — total system memory in bytes. Deviation from Node: truncates to a 32-bit int (the same tradeoff as fs.statSync's size field); on a host with more than ~2GB of RAM the value can come out negative.

console.log(os.totalmem() != 0);
os.freemem() Experimental Wasm: limited

→ int — same 32-bit truncation caveat as totalmem().

console.log(os.freemem() != 0);
os.loadavg() Wasm: limited

→ number[] — 1, 5, and 15 minute load averages, always exactly 3 elements.

const loads: number[] = os.loadavg();
console.log(loads[0]);
os.availableParallelism()

→ int

console.log(os.availableParallelism() > 0); // true
os.EOL()

→ string — always "\n" (Lumen is POSIX-only).

console.log(os.EOL() == "\n"); // true
os.devNull()

→ string — always "/dev/null".

console.log(os.devNull());