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

Function createShadowTarget

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

* Creates a clean shadow target matching the structural kind of `hostTarget` (function, array, * or plain object) so V8 Proxy invariants are checked against the shadow target while keeping * its prototype aligned with `SAFE_LOOKUP_TARGET`. * * For constructible functions, uses a bound function `

(hostTarget: HostTarget)

Source from the content-addressed store, hash-verified

348 * target has `[[Construct]]` without a fabricated non-configurable own `.prototype` property.
349 */
350function createShadowTarget(hostTarget: HostTarget): HostTarget {
351 let shadow: HostTarget;
352 if (typeof hostTarget === 'function') {
353 shadow = isConstructibleFunction(hostTarget as HostCallable) ? function () {}.bind(null) : () => {};
354 } else if (Array.isArray(hostTarget)) {
355 shadow = [];
356 } else {
357 shadow = {};
358 }
359 Reflect.setPrototypeOf(shadow, SAFE_LOOKUP_TARGET);
360 return shadow;
361}
362
363/**
364 * Clones a host property descriptor so `value` / `get` / `set` are wrapped for the VM while

Callers 1

wrapDeepFunction · 0.85

Calls 1

isConstructibleFunctionFunction · 0.85

Tested by

no test coverage detected