(prototype: any, fnNames: string[])
| 75 | } |
| 76 | |
| 77 | export function patchPrototype(prototype: any, fnNames: string[]) { |
| 78 | const source = prototype.constructor['name']; |
| 79 | for (let i = 0; i < fnNames.length; i++) { |
| 80 | const name = fnNames[i]; |
| 81 | const delegate = prototype[name]; |
| 82 | if (delegate) { |
| 83 | const prototypeDesc = ObjectGetOwnPropertyDescriptor(prototype, name); |
| 84 | if (!isPropertyWritable(prototypeDesc)) { |
| 85 | continue; |
| 86 | } |
| 87 | prototype[name] = ((delegate: Function) => { |
| 88 | const patched: any = function (this: unknown) { |
| 89 | return delegate.apply(this, bindArguments(<any>arguments, source + '.' + name)); |
| 90 | }; |
| 91 | attachOriginToPatched(patched, delegate); |
| 92 | return patched; |
| 93 | })(delegate); |
| 94 | } |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | export function isPropertyWritable(propertyDesc: any) { |
| 99 | if (!propertyDesc) { |
no test coverage detected
searching dependent graphs…