---
sidebar_position: 6
title: Runtime reference
---

# Runtime reference

## Timers

Global timer functions, behaving like their browser counterparts.

### <Fn /> setTimeout {#set-timeout}

```ts
setTimeout(callback: (...args: any[]) => void, delay: number, ...args: any[]): number
```

Runs `callback` once after `delay` ms. Returns a timer ID.

### <Fn /> clearTimeout {#clear-timeout}

```ts
clearTimeout(id: number): void
```

Cancels a pending timeout. Safe to call with an invalid ID.

### <Fn /> setInterval {#set-interval}

```ts
setInterval(callback: (...args: any[]) => void, period: number, ...args: any[]): number
```

Runs `callback` repeatedly every `period` ms. Returns a timer ID.

### <Fn /> clearInterval {#clear-interval}

```ts
clearInterval(id: number): void
```

Cancels a repeating interval.

### <Fn /> queueMicrotask {#queue-microtask}

```ts
queueMicrotask(callback: () => void): void
```

Queues `callback` as a microtask, before the next timer/IO callback.

---

## <Obj /> console {#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.

### <Fn /> console.log {#console-log}

```ts
log(...args: any[]): void
```

Logs at INFO level.

### <Fn /> console.info {#console-info}

```ts
info(...args: any[]): void
```

Logs at INFO level.

### <Fn /> console.warn {#console-warn}

```ts
warn(...args: any[]): void
```

Logs at WARN level.

### <Fn /> console.error {#console-error}

```ts
error(...args: any[]): void
```

Logs at ERROR level.

### <Fn /> console.debug {#console-debug}

```ts
debug(...args: any[]): void
```

Logs at DEBUG level.

### <Fn /> console.assert {#console-assert}

```ts
assert(condition: boolean, ...args: any[]): void
```

Logs at ERROR level if `condition` is falsy. No-op otherwise.

### <Fn /> console.clear {#console-clear}

```ts
clear(): void
```

Sends ANSI clear-screen.

### <Fn /> console.count {#console-count}

```ts
count(label?: string): void
```

Increments and prints a named counter.

### <Fn /> console.countReset {#console-count-reset}

```ts
countReset(label?: string): void
```

Resets the named counter.

### <Fn /> console.dir {#console-dir}

```ts
dir(obj: any): void
```

Pretty-prints an object.

### <Fn /> console.group {#console-group}

```ts
group(...args: any[]): void
```

Logs and increases the indent level.

### <Fn /> console.groupEnd {#console-group-end}

```ts
groupEnd(): void
```

Decreases the indent level.

### <Fn /> console.table {#console-table}

```ts
table(data: any[] | Record<string, any>): void
```

Formats an array or object as an ASCII table.

### <Fn /> console.time {#console-time}

```ts
time(label?: string): void
```

Starts a named timer.

### <Fn /> console.timeLog {#console-time-log}

```ts
timeLog(label?: string): void
```

Logs elapsed time without stopping the timer.

### <Fn /> console.timeEnd {#console-time-end}

```ts
timeEnd(label?: string): void
```

Logs elapsed time and stops the timer.

### <Fn /> console.trace {#console-trace}

```ts
trace(...args: any[]): void
```

Logs `"Trace: ..."` with optional args.

---

## 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`, `structuredClone`, `globalThis`.

:::warning No ICU
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. |
| `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. |
| `TextEncoder` / `TextDecoder` | Not present. For string → bytes, use `toUTF8` / `toUTF16` / `toUTF32` from [`yeet:tui:text`](./tui.md#text-utilities). |
| `URL` / `URLSearchParams` | Not present. |
| `AbortController` / `AbortSignal` | Not present. |
| `Event` / `EventTarget` | Not globals. `yeet:events` exports `Event`, `EventTarget`, and `ErrorEvent`, which [workers and message ports](./workers#ports) use. |
| `SharedArrayBuffer` / `Atomics` | No shared memory. `Worker` and `SharedWorker` exist, as separate isolates that talk over message ports; see [Workers](./workers). |
| `localStorage` / `sessionStorage` | Not available. |
| `document` / DOM | No DOM. |
| `requestAnimationFrame` | Use `setInterval`. |
| `XMLHttpRequest` / `FormData` / `Blob` | Not present. |
| `ReadableStream` / `WritableStream` | No WHATWG streams. |
