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

Function boundTo

ark/aot/shadow.ts:406–416  ·  view source on GitHub ↗
(target: object, value: unknown)

Source from the content-addressed store, hash-verified

404
405// binds a method, as describe() selects nodes by `this`
406const boundTo = (target: object, value: unknown) =>
407 (
408 typeof value === "function" &&
409 Object.getPrototypeOf(value) === Function.prototype &&
410 !("prototype" in value)
411 ) ?
412 new Proxy(value, {
413 apply: (method, _, args) =>
414 inArktype(() => Reflect.apply(method, target, args))
415 })
416 : value
417
418// e.g. a Module, Scope or Generic, whose members its validator must have
419const heldHandlerOf = (pair: Pair): ProxyHandler<any> => {

Callers 3

memberOfFunction · 0.85
typeHandlerOfFunction · 0.85
heldHandlerOfFunction · 0.85

Calls 2

inArktypeFunction · 0.85
applyMethod · 0.45

Tested by

no test coverage detected