MCPcopy Create free account
hub / github.com/angular/angular / extractDefListOrFactory

Function extractDefListOrFactory

packages/core/src/render3/definition.ts:646–667  ·  view source on GitHub ↗
(
  dependencies: TypeOrFactory<DependencyTypeList> | undefined,
  defExtractor: (type: Type<unknown>) => T | null,
)

Source from the content-addressed store, hash-verified

644}
645
646export function extractDefListOrFactory<T>(
647 dependencies: TypeOrFactory<DependencyTypeList> | undefined,
648 defExtractor: (type: Type<unknown>) => T | null,
649): (() => T[]) | T[] | null {
650 if (!dependencies) {
651 return null;
652 }
653
654 return () => {
655 const resolvedDependencies = typeof dependencies === 'function' ? dependencies() : dependencies;
656 const result: T[] = [];
657
658 for (const dep of resolvedDependencies) {
659 const definition = defExtractor(dep);
660 if (definition !== null) {
661 result.push(definition);
662 }
663 }
664
665 return result;
666 };
667}
668
669/**
670 * A map that contains the generated component IDs and type.

Callers 2

ɵɵsetComponentScopeFunction · 0.90
ɵɵdefineComponentFunction · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected