* 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)
| 90 | * @returns Matching PipeDef |
| 91 | */ |
| 92 | function 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. |
no test coverage detected
searching dependent graphs…