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

Function delegateGet

ark/type/deferred.ts:1371–1391  ·  view source on GitHub ↗
(
	d: Deferred,
	target: BaseRoot,
	k: PropertyKey
)

Source from the content-addressed store, hash-verified

1369}
1370
1371const delegateGet = (
1372 d: Deferred,
1373 target: BaseRoot,
1374 k: PropertyKey
1375): unknown => {
1376 const value = Reflect.get(target, k, target)
1377 if (
1378 typeof value !== "function" ||
1379 k === "constructor" ||
1380 k === "pipe" ||
1381 isNode(value)
1382 )
1383 return value
1384 // bound once, so it reads as the method it read before, as any Type's does.
1385 // Keyed by the function, so one that compiling replaces isn't answered with
1386 // what was bound before it
1387 let bound = d.bound?.get(value)
1388 if (!bound)
1389 (d.bound ??= new WeakMap()).set(value, (bound = value.bind(target)))
1390 return bound
1391}
1392
1393const shellProto = new Proxy(Object.create(proto), {
1394 get: (target, k, receiver) => {

Callers 1

deferred.tsFile · 0.85

Calls 4

isNodeFunction · 0.90
bindMethod · 0.80
getMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected