MCPcopy
hub / github.com/tldraw/tldraw / extractMatcherPaths

Function extractMatcherPaths

packages/store/src/lib/executeQuery.ts:63–82  ·  view source on GitHub ↗
(
	query: QueryExpression<any>,
	prefix: string = ''
)

Source from the content-addressed store, hash-verified

61}
62
63function extractMatcherPaths(
64 query: QueryExpression<any>,
65 prefix: string = ''
66): Array<{ path: string; matcher: QueryValueMatcher<any> }> {
67 const paths: Array<{ path: string; matcher: QueryValueMatcher<any> }> = []
68
69 for (const [key, value] of Object.entries(query)) {
70 const currentPath = prefix ? `${prefix}\\${key}` : key
71
72 if (isQueryValueMatcher(value)) {
73 // It's a direct matcher
74 paths.push({ path: currentPath, matcher: value })
75 } else if (typeof value === 'object' && value !== null) {
76 // It's a nested query - recurse into it
77 paths.push(...extractMatcherPaths(value as QueryExpression<any>, currentPath))
78 }
79 }
80
81 return paths
82}
83
84export function objectMatchesQuery<T extends object>(query: QueryExpression<T>, object: T) {
85 for (const [key, matcher] of Object.entries(query)) {

Callers 1

executeQueryFunction · 0.85

Calls 3

isQueryValueMatcherFunction · 0.85
entriesMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…