MCPcopy Create free account
hub / github.com/middleapi/orpc / apply

Function apply

packages/shared/src/proxy.ts:20–42  ·  view source on GitHub ↗
(targetFn, thisArg, args)

Source from the content-addressed store, hash-verified

18
19 return new Proxy(value, {
20 apply(targetFn, thisArg, args) {
21 /**
22 * Do nothing if .then not triggered by `await`
23 */
24 if (args.length !== 2 || args.some(arg => !isNativeFunction(arg))) {
25 return Reflect.apply(targetFn, thisArg, args)
26 }
27
28 let shouldOmit = true
29 args[0].call(thisArg, preventNativeAwait(new Proxy(target, {
30 get: (target, prop, receiver) => {
31 /**
32 * Only omit `then` once, in `await` resolution, afterwards it should become normal
33 */
34 if (shouldOmit && prop === 'then') {
35 shouldOmit = false
36 return undefined
37 }
38
39 return Reflect.get(target, prop, receiver)
40 },
41 })))
42 },
43 })
44 },
45 })

Callers

nothing calls this directly

Calls 4

isNativeFunctionFunction · 0.85
preventNativeAwaitFunction · 0.85
callMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected