| 267 | |
| 268 | assert(isFunction(Obj[methodName]), `methodName = ${methodName} ${typeof Obj[methodName]}`); |
| 269 | const fn = function () { |
| 270 | |
| 271 | // http://stackoverflow.com/questions/367768/how-to-detect-if-a-function-is-called-as-constructor |
| 272 | // Xx console.log(this.constructor.name == methodName, (this.constructor === fn), this.constructor.name); |
| 273 | return cache.__proxy(Obj, methodName, arguments, (this.constructor === fn)); |
| 274 | |
| 275 | }; |
| 276 | proxyObj[methodName] = fn; |
| 277 | // http://stackoverflow.com/questions/5871040/how-to-dynamically-set-a-function-object-name-in-javascript-as-it-is-displayed-i |
| 278 | Object.defineProperty(fn, "name", {value: methodName}); |