MCPcopy
hub / github.com/angular/angular / getPipeDef

Function getPipeDef

packages/core/src/render3/pipe.ts:92–117  ·  view source on GitHub ↗

* Searches the pipe registry for a pipe with the given name. If one is found, * returns the pipe. Otherwise, an error is thrown because the pipe cannot be resolved. * * @param name Name of pipe to resolve * @param registry Full list of available pipes * @returns Matching PipeDef

(name: string, registry: PipeDefList | null)

Source from the content-addressed store, hash-verified

90 * @returns Matching PipeDef
91 */
92function getPipeDef(name: string, registry: PipeDefList | null): PipeDef<any> | undefined {
93 if (registry) {
94 if (ngDevMode) {
95 const pipes = registry.filter((pipe) => pipe.name === name);
96 // TODO: Throw an error in the next major
97 if (pipes.length > 1) {
98 console.warn(
99 formatRuntimeError(
100 RuntimeErrorCode.MULTIPLE_MATCHING_PIPES,
101 getMultipleMatchingPipesMessage(name),
102 ),
103 );
104 }
105 }
106 for (let i = registry.length - 1; i >= 0; i--) {
107 const pipeDef = registry[i];
108 if (name === pipeDef.name) {
109 return pipeDef;
110 }
111 }
112 }
113 if (ngDevMode) {
114 throw new RuntimeError(RuntimeErrorCode.PIPE_NOT_FOUND, getPipeNotFoundErrorMessage(name));
115 }
116 return;
117}
118
119/**
120 * Generates a helpful error message for the user when multiple pipes match the name.

Callers 1

ɵɵpipeFunction · 0.70

Calls 5

formatRuntimeErrorFunction · 0.90
warnMethod · 0.65
filterMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…