(groundValue: unknown, comparisonValue: unknown)
| 65 | * a single code path, reducing duplication. |
| 66 | */ |
| 67 | export function conditionMatches(groundValue: unknown, comparisonValue: unknown): boolean { |
| 68 | const groundArr: unknown[] = Array.isArray(groundValue) ? groundValue : [groundValue] |
| 69 | |
| 70 | if (Array.isArray(comparisonValue)) { |
| 71 | return comparisonValue.some((val) => groundArr.includes(val)) |
| 72 | } |
| 73 | if (typeof comparisonValue === 'string') { |
| 74 | return groundArr.some((val) => { |
| 75 | if (comparisonValue === val) return true |
| 76 | if (REGEX_INTENT.test(comparisonValue)) { |
| 77 | return safeRegexTest(comparisonValue, String(val)) |
| 78 | } |
| 79 | return false |
| 80 | }) |
| 81 | } |
| 82 | if (typeof comparisonValue === 'boolean' || typeof comparisonValue === 'number') { |
| 83 | return groundArr.includes(comparisonValue) |
| 84 | } |
| 85 | if (typeof comparisonValue === 'object' && comparisonValue !== null) { |
| 86 | return groundArr.some((val) => isEqual(comparisonValue, val)) |
| 87 | } |
| 88 | return false |
| 89 | } |
| 90 | |
| 91 | /** Resolve a ground value from inputValues, parsing JSON-encoded arrays when found. */ |
| 92 | function resolveGroundValue(inputValues: Record<string, unknown>, rawPath: string, arrayIndex?: number): unknown { |
no test coverage detected