(proxyObj, Obj, methodName)
| 259 | const cache = new Cache(); |
| 260 | |
| 261 | function replaceFunc(proxyObj, Obj, methodName) { |
| 262 | |
| 263 | assert(proxyObj); |
| 264 | debugLog(` installing proxy method ${methodName}`); |
| 265 | |
| 266 | if (isFunction(Obj[methodName])) { |
| 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}); |
| 279 | |
| 280 | } |
| 281 | |
| 282 | } |
| 283 | |
| 284 | occ.makeBottle = shapeFactory.makeBottle; |
| 285 |
no test coverage detected