MCPcopy Create free account
hub / github.com/appium/appium / wrapDeep

Function wrapDeep

packages/execute-driver-plugin/lib/vm-host-binding.ts:698–715  ·  view source on GitHub ↗

* Returns the one deep proxy for this host target, creating and caching it on first use. * * @typeParam T - Host object or function type. * @param hostValue - Raw host reference (not a primitive). * @returns Cached or new proxy for `hostValue`.

(hostValue: T)

Source from the content-addressed store, hash-verified

696 * @returns Cached or new proxy for `hostValue`.
697 */
698function wrapDeep<T extends HostTarget>(hostValue: T): T {
699 if (typeof hostValue !== 'object' && typeof hostValue !== 'function') {
700 return hostValue;
701 }
702 const cached = targetToProxy.get(hostValue);
703 if (cached) {
704 return cached as T;
705 }
706 if (isOurProxy(hostValue) || isVmRealmValue(hostValue)) {
707 return hostValue as T;
708 }
709 const shadowTarget = createShadowTarget(hostValue);
710 shadowToHost.set(shadowTarget, hostValue);
711 const proxy = new Proxy(shadowTarget, DEEP_HANDLER);
712 targetToProxy.set(hostValue, proxy);
713 proxyToTarget.set(proxy, hostValue);
714 return proxy as T;
715}
716
717/**
718 * Recursively wraps objects and functions; leaves primitives and VM-originated values unchanged;

Callers 4

wrapPromiseAsThenableFunction · 0.85
wrapIfNeededFunction · 0.85
vm-host-binding.tsFile · 0.85

Calls 5

isOurProxyFunction · 0.85
isVmRealmValueFunction · 0.85
createShadowTargetFunction · 0.85
setMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected