(Ctor: Function)
| 587 | const symbolThenPatched = __symbol__('thenPatched'); |
| 588 | |
| 589 | function patchThen(Ctor: Function) { |
| 590 | const proto = Ctor.prototype; |
| 591 | |
| 592 | const prop = ObjectGetOwnPropertyDescriptor(proto, 'then'); |
| 593 | if (prop && (prop.writable === false || !prop.configurable)) { |
| 594 | // check Ctor.prototype.then propertyDescriptor is writable or not |
| 595 | // in meteor env, writable is false, we should ignore such case |
| 596 | return; |
| 597 | } |
| 598 | |
| 599 | const originalThen = proto.then; |
| 600 | // Keep a reference to the original method. |
| 601 | proto[symbolThen] = originalThen; |
| 602 | |
| 603 | Ctor.prototype.then = function (onResolve: any, onReject: any) { |
| 604 | const wrapped = new ZoneAwarePromise((resolve, reject) => { |
| 605 | originalThen.call(this, resolve, reject); |
| 606 | }); |
| 607 | return wrapped.then(onResolve, onReject); |
| 608 | }; |
| 609 | (Ctor as any)[symbolThenPatched] = true; |
| 610 | } |
| 611 | |
| 612 | api.patchThen = patchThen; |
| 613 |
no test coverage detected
searching dependent graphs…