MCPcopy
hub / github.com/nestjs/nest / getAllMethodNames

Method getAllMethodNames

packages/core/metadata-scanner.ts:78–120  ·  view source on GitHub ↗
(prototype: object | null)

Source from the content-addressed store, hash-verified

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}

Callers 9

reflectInjectablesMethod · 0.80
scanForPathsMethod · 0.80
actionMethod · 0.80
exploreMethod · 0.80
exploreMethod · 0.80
getWebhooksMethod · 0.80

Calls 5

isConstructorFunction · 0.90
isFunctionFunction · 0.90
hasMethod · 0.80
getMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected