( cls: Class, name: string, module: SourceModule )
| 727 | |
| 728 | // a method each instance of a class runs, unless one may replace it |
| 729 | const methodIn = ( |
| 730 | cls: Class, |
| 731 | name: string, |
| 732 | module: SourceModule |
| 733 | ): [FunctionNode, SourceModule] | undefined => { |
| 734 | let method: FunctionNode | undefined |
| 735 | for (const element of cls.body.body) { |
| 736 | if ( |
| 737 | (element.type !== "MethodDefinition" && |
| 738 | element.type !== "PropertyDefinition") || |
| 739 | element.static || |
| 740 | keyNameOf(element) !== name |
| 741 | ) |
| 742 | continue |
| 743 | const value = element.value && unwrapExpression(element.value) |
| 744 | if ( |
| 745 | method || |
| 746 | !value || |
| 747 | !isFunctionNode(value) || |
| 748 | (element.type === "MethodDefinition" && element.kind !== "method") |
| 749 | ) |
| 750 | return |
| 751 | method = value |
| 752 | } |
| 753 | return method && !replacesMember(cls, name) ? [method, module] : undefined |
| 754 | } |
| 755 | |
| 756 | // e.g. `store` read only as `store.add(...)` or `new Store()`, so nothing |
| 757 | // can replace a member its instances run |
no test coverage detected