( query: QueryExpression<any>, prefix: string = '' )
| 61 | } |
| 62 | |
| 63 | function 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 | |
| 84 | export function objectMatchesQuery<T extends object>(query: QueryExpression<T>, object: T) { |
| 85 | for (const [key, matcher] of Object.entries(query)) { |
no test coverage detected
searching dependent graphs…