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

Function changesSinceLastStep

ark/type/standalone/fallbacks.ts:149–173  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

147
148 // discovering objects as it reads them, so changes hold each reachable one
149 const changesSinceLastStep = (): Changes => {
150 const changes: Changes = []
151 // its result is only printed where it stops arktype's write
152 if (printsResults) return changes
153 for (let id = 0; id < objects.length; id++) {
154 if (++reads > maxTracedReads) {
155 tooDeep.add(root)
156 refuseReplay()
157 }
158 const o = objects[id] as Record<string, unknown>
159 const keys = Object.keys(o)
160 if (isUnchanged(keys, o, keysRead[id], valuesRead[id])) continue
161 const values = keys.map(key => o[key])
162 keysRead[id] = keys
163 valuesRead[id] = values
164 states[id] = keys.map((key, i) => {
165 const spread = markers.get(key)
166 return spread === undefined ?
167 { key, ref: refOf(values[i]) }
168 : { spread }
169 })
170 changes.push([id, states[id]])
171 }
172 return changes
173 }
174
175 const unwritten = () => {
176 const hole = copies.length

Callers 3

unwrittenFunction · 0.85
fallbackFunction · 0.85
traceFallbacksFunction · 0.85

Calls 7

refuseReplayFunction · 0.85
isUnchangedFunction · 0.85
refOfFunction · 0.85
mapMethod · 0.65
getMethod · 0.65
addMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected