MCPcopy Create free account
hub / github.com/TanStack/db / withIndexTracking

Function withIndexTracking

packages/db/tests/query/indexes.test.ts:170–186  ·  view source on GitHub ↗
(
  collection: any,
  testFn: (tracker: { stats: IndexUsageStats }) => void | Promise<void>,
)

Source from the content-addressed store, hash-verified

168
169// Helper to run a test with index usage tracking (automatically handles setup/cleanup)
170function withIndexTracking(
171 collection: any,
172 testFn: (tracker: { stats: IndexUsageStats }) => void | Promise<void>,
173): void | Promise<void> {
174 const tracker = createIndexUsageTracker(collection)
175
176 try {
177 const result = testFn(tracker)
178 if (result instanceof Promise) {
179 return result.finally(() => tracker.restore())
180 }
181 tracker.restore()
182 } catch (error) {
183 tracker.restore()
184 throw error
185 }
186}
187
188const testData: Array<TestItem> = [
189 {

Callers 1

indexes.test.tsFile · 0.70

Calls 2

testFnFunction · 0.85
createIndexUsageTrackerFunction · 0.70

Tested by

no test coverage detected