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

Method lookupComponent

packages/core/injector/injector.ts:602–633  ·  view source on GitHub ↗
(
    providers: Map<Function | string | symbol, InstanceWrapper>,
    moduleRef: Module,
    dependencyContext: InjectorDependencyContext,
    wrapper: InstanceWrapper<T>,
    resolutionContext: ResolutionContext = { contextId: STATIC_CONTEXT },
    keyOrIndex?: symbol | string | number,
  )

Source from the content-addressed store, hash-verified

600 }
601
602 public async lookupComponent<T = any>(
603 providers: Map<Function | string | symbol, InstanceWrapper>,
604 moduleRef: Module,
605 dependencyContext: InjectorDependencyContext,
606 wrapper: InstanceWrapper<T>,
607 resolutionContext: ResolutionContext = { contextId: STATIC_CONTEXT },
608 keyOrIndex?: symbol | string | number,
609 ): Promise<InstanceWrapper<T>> {
610 const token = wrapper.token || wrapper.name;
611 const { name } = dependencyContext;
612 if (wrapper && token === name) {
613 throw new UnknownDependenciesException(
614 wrapper.name,
615 dependencyContext,
616 moduleRef,
617 { id: wrapper.id },
618 );
619 }
620 if (name && providers.has(name)) {
621 const instanceWrapper = providers.get(name)!;
622 this.printFoundInModuleLog(name, moduleRef);
623 this.addDependencyMetadata(keyOrIndex!, wrapper, instanceWrapper);
624 return instanceWrapper;
625 }
626 return this.lookupComponentInParentModules(
627 dependencyContext,
628 moduleRef,
629 wrapper,
630 resolutionContext,
631 keyOrIndex,
632 );
633 }
634
635 public async lookupComponentInParentModules<T = any>(
636 dependencyContext: InjectorDependencyContext,

Callers 2

injector.spec.tsFile · 0.80

Calls 5

printFoundInModuleLogMethod · 0.95
addDependencyMetadataMethod · 0.95
hasMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected