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.
Type Parameters
Section titled “Type Parameters”State
Properties
Section titled “Properties”attach
Section titled “attach”
readonlyattach: (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.
Parameters
Section titled “Parameters”structure
Section titled “structure”object
State
Returns
Section titled “Returns”void
Throws
Section titled “Throws”With INVALID_ARGUMENT when structure
is not an extensible object, or when a state is already attached.
stateOf
Section titled “stateOf”
readonlystateOf: (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.
Parameters
Section titled “Parameters”structure
Section titled “structure”unknown
Returns
Section titled “Returns”State | undefined