Constructor
new WorldFacts(initialFactsopt)
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
initialFacts | Record.<string, any> | <optional> | null |
- Source
Classes
Members
size
Number of stored authoritative facts.
- Source
Methods
allFacts() → {Record.<string, {value: any, source: string, timestamp: number}>}
Returns all authoritative records with provenance.
- Source
- Type:
- Record.<string, {value: any, source: string, timestamp: number}>
clear()
Clears all facts.
- Source
delete(key, provenanceopt) → {boolean}
Deletes a fact and notifies listeners.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
key | string | |||
provenance | string | | <optional> | null |
- Source
- Type:
- boolean
entries() → {Array.<Array>}
Returns an array of [key, value] entries.
- Source
- Type:
- Array.<Array>
get(key, defaultValueopt) → {any}
Gets a fact value. Supports exact key, dot-notated sub-path traversal, and namespace aggregation.
| Name | Type | Attributes | Description |
|---|---|---|---|
key | string | ||
defaultValue | any | <optional> |
- Source
- Type:
- any
getFact(key) → {Object|null}
Returns full fact record including value and provenance metadata.
| Name | Type | Description |
|---|---|---|
key | string |
- Source
- Type:
- Object |
null
getProvenance(key) → {Object|null}
Returns provenance metadata for a fact.
| Name | Type | Description |
|---|---|---|
key | string |
- Source
- Type:
- Object |
null
has(key) → {boolean}
Checks whether a fact exists (exact key, nested property, or namespace).
| Name | Type | Description |
|---|---|---|
key | string |
- Source
- Type:
- boolean
keys() → {Array.<string>}
Returns an array of stored fact keys.
- Source
- Type:
- Array.<string>
offChange(unbindOrCallback)
Explicit unbind for a listener or unbind function.
| Name | Type | Description |
|---|---|---|
unbindOrCallback | function |
- Source
onChange(patternOrCallback, maybeCallbackopt) → {function}
Registers a change listener with pattern filtering and clean unbind.
onChange(callback): global listener (key, newValue, oldValue, provenance)onChange(pattern, callback): filtered listener (newValue, oldValue, provenance, key)
| Name | Type | Attributes | Description |
|---|---|---|---|
patternOrCallback | string | | ||
maybeCallback | function | <optional> |
- Source
Unbind function
- Type:
- function
restore(snapshot, optionsopt) → {this}
Restores state from a snapshot.
| Name | Type | Attributes | Description |
|---|---|---|---|
snapshot | object | ||
options | object | <optional> |
- Source
- Type:
- this
set(key, value, provenanceopt) → {this}
Sets a fact with provenance tracking.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
key | string | |||
value | any | |||
provenance | string | | <optional> | null |
- Source
- Type:
- this
snapshot() → {Object}
Creates a deep-cloned, serializable snapshot for save games.
- Source
- Type:
- Object
toObject() → {Record.<string, any>}
Returns a plain object representation of all stored facts.
- Source
- Type:
- Record.<string, any>