refactor(ngcc): share code between CommonJsReflectionHost
and UmdReflectionHost
(#34512)
While different, CommonJS and UMD have a lot in common regarding the their exports are constructed. Therefore, there was some code duplication between `CommonJsReflectionHost` and `UmdReflectionHost`. This commit extracts some of the common bits into a separate file as helpers to allow reusing the code in both `ReflectionHost`s. PR Close #34512
This commit is contained in:

committed by
Alex Rickabaugh

parent
d5fd742763
commit
17d5e2bc99
@ -66,6 +66,13 @@ export function findAll<T>(node: ts.Node, test: (node: ts.Node) => node is ts.No
|
||||
}
|
||||
}
|
||||
|
||||
export function getOrDefault<K, V>(map: Map<K, V>, key: K, factory: (key: K) => V): V {
|
||||
if (!map.has(key)) {
|
||||
map.set(key, factory(key));
|
||||
}
|
||||
return map.get(key) !;
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the given declaration have a name which is an identifier?
|
||||
* @param declaration The declaration to test.
|
||||
|
Reference in New Issue
Block a user