MCPcopy Index your code
hub / github.com/loopbackio/loopback-next / describeInjectedArguments

Function describeInjectedArguments

packages/context/src/inject.ts:571–616  ·  view source on GitHub ↗
(
  target: Object,
  method?: string,
)

Source from the content-addressed store, hash-verified

569 * @param method - Method name, undefined for constructor
570 */
571export function describeInjectedArguments(
572 target: Object,
573 method?: string,
574): Readonly<Injection>[] {
575 method = method ?? '';
576
577 // Try to read from cache
578 const cache =
579 MetadataInspector.getAllMethodMetadata<Readonly<Injection>[]>(
580 INJECT_METHODS_KEY,
581 target,
582 {
583 ownMetadataOnly: true,
584 },
585 ) ?? {};
586 let meta: Readonly<Injection>[] = cache[method];
587 if (meta) return meta;
588
589 // Build the description
590 const options: InspectionOptions = {};
591 if (method === '') {
592 if (shouldSkipBaseConstructorInjection(target)) {
593 options.ownMetadataOnly = true;
594 }
595 } else if (Object.prototype.hasOwnProperty.call(target, method)) {
596 // The method exists in the target, no injections on the super method
597 // should be honored
598 options.ownMetadataOnly = true;
599 }
600 meta =
601 MetadataInspector.getAllParameterMetadata<Readonly<Injection>>(
602 INJECT_PARAMETERS_KEY,
603 target,
604 method,
605 options,
606 ) ?? [];
607
608 // Cache the result
609 cache[method] = meta;
610 MetadataInspector.defineMetadata<MetadataMap<Readonly<Injection>[]>>(
611 INJECT_METHODS_KEY,
612 cache,
613 target,
614 );
615 return meta;
616}
617
618/**
619 * Inspect the target type for the injection to find out the corresponding

Callers 3

resolveInjectedArgumentsFunction · 0.90
inspectInjectionsFunction · 0.85
inject.unit.tsFile · 0.85

Calls 4

getAllMethodMetadataMethod · 0.80
defineMetadataMethod · 0.45

Tested by

no test coverage detected