iink-ts - v5.0.0
    Preparing search index...

    Class SymbolStore<T>

    The document's records, keyed by id and kept in stacking order.

    Generic on purpose: the constraint is TBaseSymbol because that is the type carrying id, so the same store serves the full TSymbol union and any narrower record set.

    The store hands out the records themselves, never copies. Callers read them; to change one, ask for a draft and commit it back.

    Type Parameters

    Index
    • get size(): number

      Returns number

    • get version(): number

      Bumped by every change to the document. Lets a derived value — a cache, an index, an in-flight export — tell whether what it was computed from is still current.

      Returns number

    • Parameters

      • record: T

      Returns void

    • Moves a record within the stacking order. A Map has no reordering primitive, so the entries are rebuilt in the new order — which is also why order has to be maintained here rather than by a caller splicing a list it was handed.

      Parameters

      Returns void

    • Returns void

    • Stores a draft back under its own id, in the position the record already held.

      Parameters

      • draft: TDraft<T>
      • markDirty: boolean = true

      Returns void

    • A mutable copy of the committed record, yours to change until you commit it.

      The copy is what makes the contract honest: the stored record is handed to readers as-is, so mutating it in place would change what every other reader sees, mid-frame and without a version bump. Ask for a draft, change it, commit it.

      Parameters

      • id: string

      Returns TDraft<T> | undefined

    • Parameters

      • id: string

      Returns T | undefined

    • Parameters

      • id: string

      Returns boolean

    • The records in stacking order.

      Returns T[]

    • The records grouped by whatever keys selector claims for each of them, memoized against version so a caller on a hot path can ask every frame and only pay when the document actually changed.

      selector must be a stable reference — a module-level or field-held function, not an inline closure — because it is the cache key. An inline arrow is a new key on every call and would recompute every time, which is the cost this exists to remove.

      Parameters

      • selector: (record: T) => string[]

      Returns ReadonlyMap<string, T[]>

    • Parameters

      • id: string

      Returns void

    • Swaps one record for several, in the position the original held.

      Parameters

      • id: string
      • records: T[]

      Returns void

    • Replaces the record stored under record.id. Unknown ids are ignored rather than inserted, so a stale caller cannot resurrect a deleted symbol.

      Parameters

      • record: T
      • markDirty: boolean = true

      Returns void