MCPcopy Index your code
hub / github.com/angular/angular / patchPrototype

Function patchPrototype

packages/zone.js/lib/common/utils.ts:77–96  ·  view source on GitHub ↗
(prototype: any, fnNames: string[])

Source from the content-addressed store, hash-verified

75}
76
77export 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
98export function isPropertyWritable(propertyDesc: any) {
99 if (!propertyDesc) {

Callers 2

patchBrowserFunction · 0.90
util.spec.tsFile · 0.90

Calls 2

isPropertyWritableFunction · 0.85
attachOriginToPatchedFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…