(vmFn: HostCallable, wrapped: HostCallable, includePrototype: boolean)
| 135 | } |
| 136 | |
| 137 | function 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 | |
| 160 | function runVmCallback( |
| 161 | thisArg: unknown, |
no test coverage detected