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

Method calculateModulesDistance

packages/core/scanner.ts:412–431  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

410 }
411
412 public calculateModulesDistance() {
413 const modulesGenerator = this.container.getModules().values();
414 // Skip "InternalCoreModule"
415 // The second element is the actual root module
416 modulesGenerator.next();
417
418 const rootModule = modulesGenerator.next().value!;
419 if (!rootModule) {
420 return;
421 }
422
423 // Convert modules to an acyclic connected graph
424 const tree = new TopologyTree(rootModule);
425 tree.walk((moduleRef, depth) => {
426 if (moduleRef.isGlobal) {
427 return;
428 }
429 moduleRef.distance = depth;
430 });
431 }
432
433 public async insertImport(related: any, token: string, context: string) {
434 if (isUndefined(related)) {

Callers 1

scanMethod · 0.95

Calls 3

walkMethod · 0.95
getModulesMethod · 0.45
nextMethod · 0.45

Tested by

no test coverage detected