Skip to main content

Module object

Module object 

Source
Expand description

The object model: property tables, arrays, functions, and the prototype chain.

QuickJS splits an object into a shape (the property names and their attributes, shared between objects with the same layout) and a property vector (the values). That split is a performance feature, not a semantic one, and it only pays off once objects are created in bulk; this model keeps the property table per object, in insertion order, and therefore reproduces the ordering rules directly.

Insertion order is load-bearing: for (k in o) and Object.keys iterate in the order properties were defined, with integer-like keys first in ascending order.

Structs§

BufferStorage
The bytes an ArrayBuffer owns, plus whether they have been detached.
ClassDef
What every instance of one host class shares: the engine’s half of JSClassDef.
ClassId
The id a host class is registered under: what JS_NewClassID hands out.
ClosureEnv
The reference cells a closure captured from enclosing scopes.
CompiledCode
The bytecode of one function, plus the slot-to-cell mapping.
EvalScope
The bindings a direct eval made visible, as name → cell.
FinalizationState
The mutable half of a FinalizationRegistry.
HostData
One instance of a host class: the class id, the class, and the host’s payload.
JsObject
A JavaScript object.
LocalVars
Variables a direct eval declared in one function call.
ObjectData
An object’s mutable state: its prototype, property table and internal slots.
Opaque
A pointer the engine never dereferences.
PromiseReaction
One then registration.
PromiseState
A Promise’s state, shared between the promise object and its resolve/reject functions.
Property
A property of an object.
ProxyState
The two slots of a proxy, shared with its revoke function.
Registration
One FinalizationRegistry.register call.

Enums§

Callable
The body of a callable object.
CombinatorKind
What a Promise combinator does when its elements settle.
ObjectKind
What kind of object this is.
PromiseStatus
Which of §27.2.1.2’s three states a promise is in.
PropertyKey
The mutable half of an object. What a property is keyed by.
WeakKey
A key that can be held weakly: an object, or a symbol.

Constants§

ARRAY_ELEMENT_LIMIT
The largest array index that may be stored, i.e. the largest dense vector this engine will grow to an index for.

Traits§

Exotic
The property behaviour a host class may override: the exotic half of JSClassDef.

Functions§

array_index
The array index a property key names, if it names one.
has_own
Whether object has key as an own property, arrays included.
index_value
An array index as a JavaScript number.
length_value
An array’s length as a JavaScript number.
lookup
lookup_key for a string key.
lookup_key
key on object or anywhere up its prototype chain, with the owner.
lookup_key_above
lookup_key starting above object: its prototype and upwards.
own_property_including_array
Walk the prototype chain from object looking for name.
weak_key
Turn a script value into a weak key, if CanBeHeldWeakly allows it.

Type Aliases§

HostFinalizer
A host class’s finalizer: JSClassDef::finalizer.
HostFn
A host function: a native function plus the state it captured.
HostGcMark
A host class’s gc_mark callback: JSClassDef::gc_mark.
NativeFn
A native (Rust) function reachable from JavaScript.
PromiseRef
A promise’s shareable state.
ProxyRef
A proxy’s mutable state, shared between the proxy object and its revoke.