globals
The minimal global surface installed onto a VM's global JS object.
globals
The minimal global surface installed onto a VM's global JS object.
globals.install(rt, globalObj) seeds globalThis (a self-reference), the
undefined/NaN/Infinity values, a console with log/warn/error bound to
the engine log (every line prefixed [zerojs]), Object (callable, with
Object.keys), Array (with Array.isArray), and the Error, TypeError,
RangeError, ReferenceError and SyntaxError constructors. Each error constructor
is callable with and without new; instances carry the class prototype, own
name/message/stack, and a stack captured from the interpreter's live call stack
at construction, so instanceof Error holds for every subclass. Function name and
length and prototype constructor are non-enumerable, following the realm's
enumerability model.
Interface
What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.
conforms to
zero/source-extract/v2strict
isObject(v: any) → boolean
| arg | type | description |
|---|---|---|
| v | any |
quote(s: string) → string
A string quoted for display inside a rendering: single quotes unless the text holds one, then double quotes, then backticks.
| arg | type | description |
|---|---|---|
| s | string |
formatKey(key: string) → string
| arg | type | description |
|---|---|---|
| key | string |
textWidth(s: string) → number
| arg | type | description |
|---|---|---|
| s | string |
constructorName(rt: any, o: any) → string
The name of the constructor an object was made by, when it has one.
| arg | type | description |
|---|---|---|
| rt | any | |
| o | any |
isInstanceOfGlobal(ctx: Ctx, o: any, name: string) → boolean
Whether `o` is an instance of the global constructor called `name`.
| arg | type | description |
|---|---|---|
| ctx | Ctx | |
| o | any | |
| name | string |
errorText(rt: any, o: any) → string
"<name>: <message>" for an error object, as Error.prototype.toString states it.
| arg | type | description |
|---|---|---|
| rt | any | |
| o | any |
groupArrayElements(ctx: Ctx, output: { string }, hasMore: boolean, value: any) → void
Lay out entries in columns, the way a console lays out a long array of short values: rows of equal-width cells, numbers right-aligned.
| arg | type | description |
|---|---|---|
| ctx | Ctx | |
| output | { string } | |
| hasMore | boolean | |
| value | any |
formatChild(ctx: Ctx, v: any, depth: number) → string
| arg | type | description |
|---|---|---|
| ctx | Ctx | |
| v | any | |
| depth | number |
formatObject(ctx: Ctx, o: any, depth: number) → string
| arg | type | description |
|---|---|---|
| ctx | Ctx | |
| o | any | |
| depth | number |
formatValue(ctx: Ctx, v: any, depth: number) → string
| arg | type | description |
|---|---|---|
| ctx | Ctx | |
| v | any | |
| depth | number |
newCtx(rt: any, globalObj: any, maxDepth: number?) → Ctx
| arg | type | description |
|---|---|---|
| rt | any | |
| globalObj | any | |
| maxDepth | number? |
renderArg(rt: any, globalObj: any, v: any, maxDepth: number?) → string
One value as the console shows it on its own: a string bare, anything else as `formatValue` renders it.
| arg | type | description |
|---|---|---|
| rt | any | |
| globalObj | any | |
| v | any | |
| maxDepth | number? |
joinArgs(rt: any, globalObj: any, args: { any }) → string
The line `console.log(...args)` writes. A leading string holding `%s`, `%d`, `%i`, `%f`, `%j`, `%o`, `%O`, `%c` or `%%` takes the following arguments in those places; every other argument follows, separated by spaces.
| arg | type | description |
|---|---|---|
| rt | any | |
| globalObj | any | |
| args | { any } |
tagLines(text: string) → string
Prefix each line of a console render with the package tag before it reaches the engine log.
| arg | type | description |
|---|---|---|
| text | string |
installErrors(rt: any, globalObj: any) → void
Build the Error constructor family. Each class is callable with and without `new`; instances get the class proto, own name/message/stack, and a stack captured from the interpreter's live call stack at construction.
| arg | type | description |
|---|---|---|
| rt | any | |
| globalObj | any |
construct(_rt: any, args: { any }) → any
| arg | type | description |
|---|---|---|
| _rt | any | |
| args | { any } |
call(rt2: any, _this: any, args: { any }) → void
| arg | type | description |
|---|---|---|
| rt2 | any | |
| _this | any | |
| args | { any } |
construct(rt2: any, args: { any }, _newTarget: any) → void
| arg | type | description |
|---|---|---|
| rt2 | any | |
| args | { any } | |
| _newTarget | any |
installConsole(rt: any, globalObj: any, sinks: ConsoleSinks?) → void
| arg | type | description |
|---|---|---|
| rt | any | |
| globalObj | any | |
| sinks | ConsoleSinks? |
writerFor(level: string) → void
| arg | type | description |
|---|---|---|
| level | string |
method(name: string, level: string, render: ((args: { any }) → void
| arg | type | description |
|---|---|---|
| name | string | |
| level | string | |
| render | ((args: { any } |
call(_rt: any, _this: any, args: { any }) → void
| arg | type | description |
|---|---|---|
| _rt | any | |
| _this | any | |
| args | { any } |
call(_rt: any, _this: any, args: { any }) → void
| arg | type | description |
|---|---|---|
| _rt | any | |
| _this | any | |
| args | { any } |
installPerformance(rt: any, globalObj: any) → void
Install `performance`: `now()` is a monotonic reading in milliseconds since the realm was created, and `timeOrigin` is the epoch time of that moment.
| arg | type | description |
|---|---|---|
| rt | any | |
| globalObj | any |
isCallable(v: any) → boolean
Report whether a JS value is callable: an object carrying a native/JS call.
| arg | type | description |
|---|---|---|
| v | any |
installQueueMicrotask(rt: any, globalObj: any, loop: any) → void
Install the JS global `queueMicrotask(fn)`, which enqueues a microtask on the VM's loop that invokes `fn` with no arguments and `this` undefined. A non-callable argument throws a TypeError, matching Node's contract.
| arg | type | description |
|---|---|---|
| rt | any | |
| globalObj | any | |
| loop | any |
call(_rt: any, _this: any, args: { any }) → void
| arg | type | description |
|---|---|---|
| _rt | any | |
| _this | any | |
| args | { any } |
coerceDelay(rt: any, v: any) → number
Coerce a JS delay argument to a whole non-negative millisecond count. ToNumber runs first (per HTML's timer steps); NaN and negatives clamp to 0, matching browser and Node behaviour where a bad delay schedules for the next turn.
| arg | type | description |
|---|---|---|
| rt | any | |
| v | any |
installTimers(rt: any, globalObj: any, loop: any) → void
Install the JS timer globals `setTimeout`/`setInterval` and their `clearTimeout`/`clearInterval` cancellers onto `globalObj`, backed by the VM's loop. `setTimeout(fn, delay?, ...args)` arms a one-shot timer that invokes `fn` with `...args` and `this` undefined after `delay` ms; `setInterval` arms a repeating timer. Both return the loop's numeric id. A non-callable `fn` throws a TypeError; the delay is coerced via ToNumber with NaN/negative clamped to 0. `clearTimeout` and `clearInterval` both drop the timer of the given id and are interchangeable across one-shot and interval ids, matching the runtime reality that the two id spaces are shared.
| arg | type | description |
|---|---|---|
| rt | any | |
| globalObj | any | |
| loop | any |
armGlobal(name: string, repeating: boolean) → any
| arg | type | description |
|---|---|---|
| name | string | |
| repeating | boolean |
call(_rt: any, _this: any, args: { any }) → void
| arg | type | description |
|---|---|---|
| _rt | any | |
| _this | any | |
| args | { any } |
invoke( ) → void
canceller(name: string) → any
| arg | type | description |
|---|---|---|
| name | string |
call(_rt: any, _this: any, args: { any }) → void
| arg | type | description |
|---|---|---|
| _rt | any | |
| _this | any | |
| args | { any } |
install(rt: any, globalObj: any, loop: any, sinks: ConsoleSinks?) → void
Install the global surface onto `globalObj` and wire it as the JS global object so undeclared reads and top-level assignments resolve through it. The Object surface, the Array surface, Function.prototype, and the global conversion and parsing functions come from stdlib.install. `loop` is the VM's event loop, backing the asynchronous globals such as queueMicrotask.
| arg | type | description |
|---|---|---|
| rt | any | |
| globalObj | any | |
| loop | any | |
| sinks | ConsoleSinks? |
ConsoleSinks = {Sub-parts
Everything contained inside this part. Assets are composite children (clickable cards). Files are leaf payloads. Expand any row to view its source.
Showing up to 3 levels deep. Open a part to see what it holds further down.
Problems
Everything affecting this asset right now: its own problems, anything wrong inside it, and problems on its direct dependencies.
agent_score is exposed.+ quality × 0.35
+ performance × 0.25
± compat factor
Usability ratings
Did the part work as advertised when consumers tried to drop it in. Separate from upvotes: those are taste; this is "did it function".
Scoped to this part · feeds back into the world's score.