Preparing search index...

    Function makeItemIndexCache

    • Returns a corpus-keyed cache function that builds an ItemSearchIndex<T> on first access for a given corpus reference and returns the same instance on subsequent calls with the same reference.

      Callers hold the returned getter at module scope so the WeakMap lifetime matches the module, not any component tree. When the corpus array is replaced (e.g. after a DB mutation via useSyncExternalStore), the old entry is automatically garbage-collected.

      Type Parameters

      • T

      Parameters

      Returns (corpus: T[]) => ItemSearchIndex<T>