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

Function copyFunctionMetadata

packages/execute-driver-plugin/lib/vm-host-binding.ts:137–158  ·  view source on GitHub ↗
(vmFn: HostCallable, wrapped: HostCallable, includePrototype: boolean)

Source from the content-addressed store, hash-verified

135}
136
137function copyFunctionMetadata(vmFn: HostCallable, wrapped: HostCallable, includePrototype: boolean): void {
138 for (const key of ['length', 'name'] as const) {
139 const desc = Reflect.getOwnPropertyDescriptor(vmFn, key);
140 if (desc) {
141 Reflect.defineProperty(wrapped, key, mapDescriptorForHost(desc));
142 }
143 }
144 if (includePrototype) {
145 const protoDesc = Reflect.getOwnPropertyDescriptor(vmFn, 'prototype');
146 if (protoDesc && 'value' in protoDesc) {
147 Reflect.defineProperty(wrapped, 'prototype', {
148 value: unwrapIfProxy(protoDesc.value),
149 writable: Boolean(protoDesc.writable),
150 });
151 }
152 }
153 Object.defineProperty(wrapped, 'toString', {
154 value: () => Function.prototype.toString.call(vmFn),
155 configurable: true,
156 writable: true,
157 });
158}
159
160function runVmCallback(
161 thisArg: unknown,

Callers 1

wrapVmFunctionForHostFunction · 0.85

Calls 2

mapDescriptorForHostFunction · 0.85
unwrapIfProxyFunction · 0.85

Tested by

no test coverage detected