Skip to content

Defined in: packages/wire/src/state-bridge.ts:20

The bridge a package’s factories and serializers share to reach state that has no place in the public interface, without widening that interface and without instanceof-style dispatch.

State

readonly attach: (structure, state) => void

Defined in: packages/wire/src/state-bridge.ts:29

Attach state to structure as a non-enumerable own property, so Object.keys, for...in, JSON.stringify, and spread copies never observe it.

object

State

void

With INVALID_ARGUMENT when structure is not an extensible object, or when a state is already attached.


readonly stateOf: (structure) => State | undefined

Defined in: packages/wire/src/state-bridge.ts:42

Return the state attached to structure, or undefined when it carries none. Structural: a structure produced by another copy of the package is readable here, and a foreign object is simply undefined, which the caller maps to its own FOREIGN_STRUCTURE code.

Reads the own data property only. An inherited descriptor is not state, and an accessor is neither read nor invoked, so an object cannot run caller-supplied code through a getter. A Proxy can still observe the descriptor read itself; the bridge narrows what an ordinary object can do, not what a hostile proxy can intercept.

unknown

State | undefined