( found: ObservedIssue[], issues: ObservedIssue[], counterparts: Map<object, unknown> )
| 899 | |
| 900 | // arktype's issues alike a first-issue validator's, all at one path |
| 901 | const firstIssueOf = ( |
| 902 | found: ObservedIssue[], |
| 903 | issues: ObservedIssue[], |
| 904 | counterparts: Map<object, unknown> |
| 905 | ): ObservedIssue[] | undefined => { |
| 906 | const unmatched = [...issues] |
| 907 | const matched: ObservedIssue[] = [] |
| 908 | for (const issue of found) { |
| 909 | const i = unmatched.findIndex( |
| 910 | candidate => |
| 911 | pathKeyOf(candidate.path) === pathKeyOf(found[0].path) && |
| 912 | isAlike(candidate, issue, { counterparts: new Map(counterparts) }) |
| 913 | ) |
| 914 | if (i === -1) return |
| 915 | matched.push(...unmatched.splice(i, 1)) |
| 916 | } |
| 917 | return matched.length ? matched : undefined |
| 918 | } |
| 919 | |
| 920 | type ObservedIssue = Omit<KeptIssue, "data"> |
| 921 |
no test coverage detected