MCPcopy Index your code
hub / github.com/TanStack/db / intersectSets

Function intersectSets

packages/db/src/utils/index-optimization.ts:75–90  ·  view source on GitHub ↗
(sets: Array<Set<T>>)

Source from the content-addressed store, hash-verified

73 * Intersects multiple sets (AND logic)
74 */
75export function intersectSets<T>(sets: Array<Set<T>>): Set<T> {
76 if (sets.length === 0) return new Set()
77 if (sets.length === 1) return new Set(sets[0])
78
79 let result = new Set(sets[0])
80 for (let i = 1; i < sets.length; i++) {
81 const newResult = new Set<T>()
82 for (const item of result) {
83 if (sets[i]!.has(item)) {
84 newResult.add(item)
85 }
86 }
87 result = newResult
88 }
89 return result
90}
91
92/**
93 * Unions multiple sets (OR logic)

Callers 1

optimizeAndExpressionFunction · 0.85

Calls 2

hasMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected