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

Function callbackOf

ark/aot/shadow.ts:523–540  ·  view source on GitHub ↗
(value: unknown, isProved: boolean)

Source from the content-addressed store, hash-verified

521
522// one per function, so its `name`, `length` and identity are the program's
523const callbackOf = (value: unknown, isProved: boolean): unknown => {
524 if (typeof value !== "function") return value
525 if (isProved) provedCallbacks.add(value)
526 let wrapper = wrapperByCallback.get(value)
527 if (!wrapper) {
528 wrapper = new Proxy(value, {
529 apply: (target, receiver, args) =>
530 !validation || validation.phase === "run" ?
531 settle(outcomeOfCall(target, receiver, args))
532 : validation.phase === "record" ?
533 record(validation, target, receiver, args)
534 : replay(validation, target, receiver, args)
535 })
536 wrapperByCallback.set(value, wrapper)
537 callbackByWrapper.set(wrapper, value)
538 }
539 return wrapper
540}
541
542const outcomeOfCall = (
543 callee: Function,

Callers 1

shadowUnderFunction · 0.85

Calls 7

outcomeOfCallFunction · 0.85
replayFunction · 0.85
settleFunction · 0.70
recordFunction · 0.70
getMethod · 0.65
addMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected