MCPcopy
hub / github.com/Effect-TS/effect / get

Function get

packages/effect/src/Effect.ts:13439–13468  ·  view source on GitHub ↗
(target: any, prop: any, receiver)

Source from the content-addressed store, hash-verified

13437 const cache = new Map()
13438 return new Proxy(TagClass, {
13439 get(target: any, prop: any, receiver) {
13440 if (prop in target) {
13441 return Reflect.get(target, prop, receiver)
13442 }
13443 if (cache.has(prop)) {
13444 return cache.get(prop)
13445 }
13446 const fn = (...args: Array<any>) =>
13447 core.andThen(target, (s: any) => {
13448 if (typeof s[prop] === "function") {
13449 cache.set(prop, (...args: Array<any>) => core.andThen(target, (s: any) => s[prop](...args)))
13450 return s[prop](...args)
13451 }
13452 cache.set(prop, core.andThen(target, (s: any) => s[prop]))
13453 return s[prop]
13454 })
13455 const cn = core.andThen(target, (s: any) => s[prop])
13456 // @effect-diagnostics-next-line floatingEffect:off
13457 Object.assign(fn, cn)
13458 const apply = fn.apply
13459 const bind = fn.bind
13460 const call = fn.call
13461 const proto = Object.setPrototypeOf({}, Object.getPrototypeOf(cn))
13462 proto.apply = apply
13463 proto.bind = bind
13464 proto.call = call
13465 Object.setPrototypeOf(fn, proto)
13466 cache.set(prop, fn)
13467 return fn
13468 }
13469 })
13470}
13471

Callers

nothing calls this directly

Calls 5

syncMethod · 0.80
mapFunction · 0.70
getMethod · 0.65
setMethod · 0.65
provideMethod · 0.65

Tested by

no test coverage detected