(prototype: object | null)
| 76 | } |
| 77 | |
| 78 | public getAllMethodNames(prototype: object | null): string[] { |
| 79 | if (!prototype) { |
| 80 | return []; |
| 81 | } |
| 82 | |
| 83 | if (this.cachedScannedPrototypes.has(prototype)) { |
| 84 | return this.cachedScannedPrototypes.get(prototype)!; |
| 85 | } |
| 86 | |
| 87 | const visitedNames = new Map<string, boolean>(); |
| 88 | const result: string[] = []; |
| 89 | |
| 90 | this.cachedScannedPrototypes.set(prototype, result); |
| 91 | |
| 92 | do { |
| 93 | for (const property of Object.getOwnPropertyNames(prototype)) { |
| 94 | if (visitedNames.has(property)) { |
| 95 | continue; |
| 96 | } |
| 97 | |
| 98 | visitedNames.set(property, true); |
| 99 | |
| 100 | // reason: https://github.com/nestjs/nest/pull/10821#issuecomment-1411916533 |
| 101 | const descriptor = Object.getOwnPropertyDescriptor(prototype, property); |
| 102 | |
| 103 | if ( |
| 104 | descriptor!.set || |
| 105 | descriptor!.get || |
| 106 | isConstructor(property) || |
| 107 | !isFunction(prototype[property]) |
| 108 | ) { |
| 109 | continue; |
| 110 | } |
| 111 | |
| 112 | result.push(property); |
| 113 | } |
| 114 | } while ( |
| 115 | (prototype = Reflect.getPrototypeOf(prototype)) && |
| 116 | prototype !== Object.prototype |
| 117 | ); |
| 118 | |
| 119 | return result; |
| 120 | } |
| 121 | } |
no test coverage detected