Runtime reference
Timers
Global timer functions, behaving like their browser counterparts.
F setTimeout
setTimeout(callback: (...args: any[]) => void, delay: number, ...args: any[]): number
Runs callback once after delay ms. Returns a timer ID.
F clearTimeout
clearTimeout(id: number): void
Cancels a pending timeout. Safe to call with an invalid ID.
F setInterval
setInterval(callback: (...args: any[]) => void, period: number, ...args: any[]): number
Runs callback repeatedly every period ms. Returns a timer ID.
F clearInterval
clearInterval(id: number): void
Cancels a repeating interval.
F queueMicrotask
queueMicrotask(callback: () => void): void
Queues callback as a microtask, before the next timer/IO callback.
O console
All output is forwarded to the daemon event stream and, if a PTY is attached, written directly to it. Arguments are space-joined. No %s / %d printf-style substitution.
F console.log
log(...args: any[]): void
Logs at INFO level.
F console.info
info(...args: any[]): void
Logs at INFO level.
F console.warn
warn(...args: any[]): void
Logs at WARN level.
F console.error
error(...args: any[]): void
Logs at ERROR level.
F console.debug
debug(...args: any[]): void
Logs at DEBUG level.
F console.assert
assert(condition: boolean, ...args: any[]): void
Logs at ERROR level if condition is falsy. No-op otherwise.
F console.clear
clear(): void
Sends ANSI clear-screen.
F console.count
count(label?: string): void
Increments and prints a named counter.
F console.countReset
countReset(label?: string): void
Resets the named counter.
F console.dir
dir(obj: any): void
Pretty-prints an object.
F console.group
group(...args: any[]): void
Logs and increases the indent level.
F console.groupEnd
groupEnd(): void
Decreases the indent level.
F console.table
table(data: any[] | Record<string, any>): void
Formats an array or object as an ASCII table.
F console.time
time(label?: string): void
Starts a named timer.
F console.timeLog
timeLog(label?: string): void
Logs elapsed time without stopping the timer.
F console.timeEnd
timeEnd(label?: string): void
Logs elapsed time and stops the timer.
F console.trace
trace(...args: any[]): void
Logs "Trace: ..." with optional args.
Text encoding
The web's TextEncoder and TextDecoder, following the Encoding Standard. Both are globals in every isolate, workers included.
O TextEncoder
class TextEncoder {
readonly encoding: "utf-8";
encode(input?: string): Uint8Array;
encodeInto(source: string, destination: Uint8Array): { read: number; written: number };
}
Encodes strings as UTF-8, the only encoding the standard encodes to. encodeInto writes as much of source as fits without splitting a character. read counts UTF-16 code units, written counts bytes. For UTF-16 or UTF-32 code units, use toUTF16 / toUTF32 from yeet:tui:text.
O TextDecoder
class TextDecoder {
constructor(label?: string, options?: { fatal?: boolean; ignoreBOM?: boolean });
readonly encoding: string;
readonly fatal: boolean;
readonly ignoreBOM: boolean;
decode(input?: ArrayBuffer | ArrayBufferView, options?: { stream?: boolean }): string;
}
Decodes bytes in any encoding the standard names. label is any of its labels ("utf-8", "utf-16le", "utf-16be", "windows-1252", "shift_jis", …), and encoding is the canonical name it resolves to. An unknown label throws RangeError. With fatal, malformed input throws TypeError instead of decoding to U+FFFD. With ignoreBOM, a leading byte order mark stays in the output. With { stream: true }, a character split across calls carries over to the next decode.
const bytes = new TextEncoder().encode("héllo"); // Uint8Array(6)
new TextDecoder().decode(bytes); // "héllo"
const dec = new TextDecoder("utf-8");
dec.decode(bytes.subarray(0, 2), { stream: true }); // "h"
dec.decode(bytes.subarray(2)); // "éllo"
Other globals
P self
self: typeof globalThis
The global object, in every script and every worker, as in a browser, Deno, or Bun. In a worker, self.name is the worker's name.
F structuredClone
structuredClone<T>(value: T, options?: { transfer?: (MessagePort | ArrayBuffer)[] }): T
Returns a deep copy of value, made as a message to a worker is. See structuredClone.
O DOMException
new DOMException(message?: string, name?: string)
The web's DOMException: an Error that name classifies, "Error" by default. code is the web's legacy code for name, or 0. A value that cannot be cloned throws one named DataCloneError, with code 25.
F reportError
reportError(error: any): void
Reports error as an uncaught exception. The global fires an error event first, placed where error was made (or at the call, for a value with no stack). A listener that calls preventDefault(), or an onerror that returns true, handles it. Otherwise it prints as an uncaught exception, and then:
- In the script
yeet runstarted, the script ends andyeet runexits non-zero, as in Bun and Deno. - In a worker, the worker keeps running, as on the web. A dedicated worker's opener hears it on its
Workeras anerrorevent; see worker errors.
Throws a TypeError when called with no argument.
V8 built-ins
All standard ECMAScript built-ins are available: Array, Object, Map, Set, WeakMap, WeakSet, Promise, Proxy, Reflect, Symbol, BigInt, RegExp, Date, Error, JSON, Math, ArrayBuffer, TypedArrays, DataView, WeakRef, FinalizationRegistry, globalThis.
This V8 build is compiled without ICU. The Intl.* namespace is unsafe to use. In particular, String.prototype.localeCompare throws RangeError: Internal error. Icu error. Use plain < / > comparisons for sorting and format numbers/dates manually.
What is NOT available
Node.js / Deno APIs
| Missing API | Notes |
|---|---|
process | No process.env, process.argv, process.exit(), etc. Use yeet.args for arguments. |
require() | Use import / ES modules only. |
__dirname / __filename | Not defined. Use import.meta.dirname / import.meta.filename. |
Buffer | Use Uint8Array / ArrayBuffer. |
fs | No file system access. |
path / os | Not available. |
child_process / exec | No subprocess spawning. |
net / http / https | No socket or HTTP APIs. |
setImmediate | Use queueMicrotask() or setTimeout(fn, 0). |
performance | No performance.now(). |
Browser APIs
| Missing API | Notes |
|---|---|
fetch | No HTTP client. Data comes through yeet.graph. |
WebSocket | Not available. |
crypto / SubtleCrypto | Not available. |
TextEncoderStream / TextDecoderStream | Not present. Use TextDecoder with { stream: true }. |
URL / URLSearchParams | Not present. |
AbortController / AbortSignal | Not present. |
Event / EventTarget | Not globals. yeet:events exports Event, EventTarget, and ErrorEvent, which workers and message ports use. |
SharedArrayBuffer / Atomics | No shared memory. Worker and SharedWorker exist, as separate isolates that talk over message ports; see Workers. |
localStorage / sessionStorage | Not available. |
document / DOM | No DOM. |
requestAnimationFrame | Use setInterval. |
XMLHttpRequest / FormData / Blob | Not present. |
ReadableStream / WritableStream | No WHATWG streams. |