MCPcopy Create free account
hub / github.com/arktypeio/arktype / firstIssueOf

Function firstIssueOf

ark/aot/shadow.ts:901–918  ·  view source on GitHub ↗
(
	found: ObservedIssue[],
	issues: ObservedIssue[],
	counterparts: Map<object, unknown>
)

Source from the content-addressed store, hash-verified

899
900// arktype's issues alike a first-issue validator's, all at one path
901const 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
920type ObservedIssue = Omit<KeptIssue, "data">
921

Callers 1

validateBothFunction · 0.85

Calls 3

pathKeyOfFunction · 0.90
isAlikeFunction · 0.70
pushMethod · 0.45

Tested by

no test coverage detected