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

Function isSpreadableObjectDef

ark/aot/droppedNarrow.ts:79–115  ·  view source on GitHub ↗
(
	def: unknown,
	scope: BaseScope,
	seen = new Set<unknown>()
)

Source from the content-addressed store, hash-verified

77 !!before.inner.predicate?.some(isUserPredicate)
78
79const isSpreadableObjectDef = (
80 def: unknown,
81 scope: BaseScope,
82 seen = new Set<unknown>()
83): boolean => {
84 if (hasArkKind(def, "root")) {
85 return (
86 (def.is("domain") && def.domain === "object") ||
87 (def.is("intersection") &&
88 !!def.basis?.is("domain") &&
89 def.basis.domain === "object")
90 )
91 }
92 if (typeof def === "string") {
93 if (def === "object") return true
94 if (seen.has(def)) return false
95 seen.add(def)
96 const resolved = scope.res[def]
97 if (hasArkKind(resolved, "root"))
98 return isSpreadableObjectDef(resolved, scope, seen)
99 if (hasOwn(scope.aliases, def))
100 return isSpreadableObjectDef(scope.aliases[def], scope, seen)
101 return false
102 }
103 if (Array.isArray(def)) {
104 if (def.length === 3 && (def[1] === ":" || def[1] === "@"))
105 return isSpreadableObjectDef(def[0], scope, seen)
106 if (def.length === 3 && def[1] === "&") {
107 return (
108 isSpreadableObjectDef(def[0], scope, new Set(seen)) &&
109 isSpreadableObjectDef(def[2], scope, new Set(seen))
110 )
111 }
112 return false
113 }
114 return isPlainContainer(def)
115}
116
117const hasUserPredicatesOf = (
118 afterBranch: BaseRoot,

Callers 1

defDropsUserPredicateFunction · 0.85

Calls 6

hasArkKindFunction · 0.90
hasOwnFunction · 0.90
isPlainContainerFunction · 0.90
isMethod · 0.80
hasMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected