Skip to main content
Every Ant script has access to a set of globals without any imports. These include the Ant runtime object, a Node.js-compatible process, standard Web APIs like fetch and crypto, and familiar timer functions. This page documents everything available at the top level of your scripts.

The Ant object

The Ant global exposes runtime metadata and a handful of utilities. It is always available — you never need to import it.

Runtime properties

Ant.version
string
The runtime version string, set at build time (e.g. "0.1.0").
Ant.target
string
The build target platform (e.g. "x86_64-linux").
Ant.revision
string
The git hash of the build, useful for bug reports and diagnostics.
Ant.buildDate
string
The build timestamp as an ISO string.
Ant.host
string
The host OS type (e.g. "linux", "macos", "windows").
console.log(Ant.version);    // e.g. "0.1.0"
console.log(Ant.target);     // e.g. "x86_64-linux"
console.log(Ant.revision);   // e.g. "a3f8c21"
console.log(Ant.buildDate);  // e.g. "2026-04-09T12:00:00Z"
console.log(Ant.host);       // e.g. "linux"

Ant.typeof(value)

Ant.typeof gives you a more detailed type name than JavaScript’s built-in typeof. It distinguishes between arrays, promises, generators, and several runtime-internal types that typeof collapses to "object" or "function".
Ant.typeof(value)
function
Returns a string type name for value. Possible values:
Return valueDescription
'object'Plain object
'string'String primitive
'array'Array instance
'function'JS function
'cfunc'Native C function
'promise'Promise instance
'generator'Generator object
'undefined'undefined
'null'null
'boolean'Boolean primitive
'number'Number primitive
'bigint'BigInt primitive
'symbol'Symbol primitive
'err'Error object
'typedarray'Typed array (e.g. Uint8Array)
'ffi'FFI handle
'ntarg'Native argument object
Ant.typeof([]);              // 'array'
Ant.typeof(Promise.resolve()); // 'promise'
Ant.typeof(null);            // 'null'
Ant.typeof(42n);             // 'bigint'
Ant.typeof(function*(){});   // 'generator'

Ant.inspect(...args)

Ant.inspect is an alias for console.inspect. It pretty-prints values to stdout, showing the full structure of objects and arrays.
Ant.inspect({ foo: [1, 2, 3], bar: new Uint8Array([0xff]) });

The process global

Ant provides a Node.js-compatible process global. It is populated by the runtime before your script runs.

Version and compatibility

console.log(process.version);     // "v25.9.0"
console.log(process.versions.ant); // Ant runtime version
console.log(process.features);
// { uv: true, tls: 'BoringSSL', typescript: 'transform' }
process.version
string
Node.js compatibility version string ("v25.9.0"). Present for compatibility with modules that check process.version.
process.versions
object
Versions of all embedded libraries. Keys include: ant, node, brotli, llhttp, nghttp2, simdjson, pcre2, libffi, lmdb, utf8proc, zlib, v8, uv, modules, napi, wamr, boringssl.
process.features
object
Feature flags for the runtime:
  • uv: true — libuv event loop is active
  • tls: 'BoringSSL' — TLS provider
  • typescript: 'transform' — TypeScript is stripped at load time

Process utilities

process.argv
string[]
Command-line arguments. argv[0] is "ant", argv[1] is your script path.
process.env
object
Environment variables as key-value strings.
process.platform
string
The operating system platform (e.g. "linux", "darwin", "win32").
process.cwd()
function
Returns the current working directory as a string.
process.exit(code?)
function
Exits the process. Optional exit code defaults to 0.
const [, , ...args] = process.argv;
const port = process.env.PORT ?? '8000';

if (args.includes('--help')) {
  console.log('Usage: ant server.js');
  process.exit(0);
}

Web standard globals

Ant includes a comprehensive set of Web APIs at the global scope, matching what browsers and WinterTC-compliant runtimes expose.

Network

GlobalDescription
fetch(url, init?)WinterTC-compatible HTTP client. See the fetch page.
RequestRepresents an HTTP request.
ResponseRepresents an HTTP response.
HeadersHTTP headers collection.

URL handling

GlobalDescription
URLWHATWG URL parser.
URLSearchParamsQuery string builder and parser.
const url = new URL('https://example.com/path?foo=bar');
console.log(url.pathname);      // "/path"
console.log(url.searchParams.get('foo')); // "bar"

Text encoding

GlobalDescription
TextEncoderEncodes strings to Uint8Array (UTF-8).
TextDecoderDecodes Uint8Array back to a string.
const encoder = new TextEncoder();
const bytes = encoder.encode('Hello, Ant!');

const decoder = new TextDecoder();
console.log(decoder.decode(bytes)); // "Hello, Ant!"

Timers

GlobalDescription
setTimeout(fn, ms)Calls fn once after ms milliseconds.
setInterval(fn, ms)Calls fn repeatedly every ms milliseconds.
clearTimeout(id)Cancels a setTimeout.
clearInterval(id)Cancels a setInterval.

Async utilities

GlobalDescription
PromiseStandard ES Promise.
queueMicrotask(fn)Schedules fn in the microtask queue.
structuredClone(value)Deep-clones a value using the structured clone algorithm.

Cryptography

crypto exposes the Web Crypto API as a global. See the crypto page for full details.
const id = crypto.randomUUID();
const buf = new Uint8Array(16);
crypto.getRandomValues(buf);

Storage

GlobalDescription
localStoragePersistent key-value storage (survives process restart).
sessionStorageIn-memory key-value storage (cleared on exit).

WebAssembly

WebAssembly is available globally. Ant uses the WAMR (WebAssembly Micro Runtime) engine.
import { readFile } from 'ant:fs';

const bytes = await readFile('module.wasm');
const { instance } = await WebAssembly.instantiate(bytes, {
  wasi: { args: process.argv.slice(2) }
});

instance.exports._start();

Module meta

When running a file directly, Ant sets two convenience globals:
GlobalDescription
__dirnameDirectory of the current file (absolute path).
__filenameFull path of the current file.
You can also use the ESM equivalent:
import { join } from 'ant:path';

const dir = import.meta.dirname;
const file = join(dir, 'data.json');

console

The console global matches the browser interface with one addition — console.inspect for structured pretty-printing.
MethodDescription
console.log(...args)Logs to stdout.
console.error(...args)Logs to stderr.
console.warn(...args)Logs a warning to stderr.
console.info(...args)Logs informational output.
console.debug(...args)Logs debug output.
console.inspect(...args)Pretty-prints values with full structure.