Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | 48x 46x 27x 27x 19x 13x 13x 11x 24x 2x 6x 6x 4x 4x 6x | export function extractTextChunks(value: unknown): string[] {
if (value === null || value === undefined) return []
if (typeof value === 'string') {
const trimmed = value.trim()
return trimmed ? [trimmed] : []
}
if (Array.isArray(value)) {
return value.flatMap((entry) => extractTextChunks(entry))
}
if (typeof value === 'object') {
return Object.values(value as Record<string, unknown>).flatMap((entry) =>
extractTextChunks(entry)
)
}
return []
}
export function matchesTextQuery(value: unknown, query: string): boolean {
const normalizedQuery = query.trim().toLowerCase()
if (!normalizedQuery) return true
const haystack = extractTextChunks(value).join(' ').toLowerCase()
const terms = normalizedQuery.split(/\s+/).filter(Boolean)
return terms.every((term) => haystack.includes(term))
}
|