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

Function dropsUserPredicate

ark/aot/droppedNarrow.ts:130–152  ·  view source on GitHub ↗
(
	before: BaseRoot,
	after?: BaseRoot,
	inIntersection = false
)

Source from the content-addressed store, hash-verified

128// `after` no longer preserves (e.g. `.partial()` / `.required()` preserve
129// unchanged branches at runtime)
130const dropsUserPredicate = (
131 before: BaseRoot,
132 after?: BaseRoot,
133 inIntersection = false
134): boolean => {
135 for (const branch of before.branches) {
136 if (!branch.is("intersection") || !branch.inner.predicate) continue
137 const userPredicates = branch.inner.predicate.filter(isUserPredicate)
138 if (!userPredicates.length) continue
139 if (
140 !after?.branches.some(
141 afterBranch =>
142 afterBranch === branch ||
143 afterBranch.equals(branch) ||
144 (inIntersection &&
145 hasUserPredicatesOf(afterBranch, userPredicates) &&
146 afterBranch.extends(branch))
147 )
148 )
149 return true
150 }
151 return false
152}
153
154const structuralRootMethods = new Map<Function, DroppedNarrowOp>([
155 [BaseRoot.prototype.merge, ".merge()"],

Callers 3

recordDroppedNarrowsFunction · 0.85
defDropsUserPredicateFunction · 0.85
checkStringGenericDropsFunction · 0.85

Calls 5

hasUserPredicatesOfFunction · 0.85
isMethod · 0.80
filterMethod · 0.80
extendsMethod · 0.80
equalsMethod · 0.65

Tested by

no test coverage detected