MCPcopy Create free account
hub / github.com/UI5/webcomponents / getSharedResource

Function getSharedResource

packages/base/src/getSharedResource.ts:26–44  ·  view source on GitHub ↗
(namespace: string, initialValue: T)

Source from the content-addressed store, hash-verified

24 * @returns {*}
25 */
26const getSharedResource = <T>(namespace: string, initialValue: T): T => {
27 const parts = namespace.split(".");
28 let current = getSharedResourcesInstance() as Record<string, any>;
29
30 if (!current) {
31 return initialValue;
32 }
33
34 for (let i = 0; i < parts.length; i++) {
35 const part = parts[i];
36 const lastPart = i === parts.length - 1;
37 if (!Object.prototype.hasOwnProperty.call(current, part)) {
38 current[part] = lastPart ? initialValue : {};
39 }
40 current = current[part];
41 }
42
43 return current as T;
44};
45
46export default getSharedResource;

Callers 13

Runtimes.tsFile · 0.85
patchPopup.tsFile · 0.85
initMethod · 0.85
destroyMethod · 0.85
getEventProviderFunction · 0.85
getCustomCSSForFunction · 0.85
Illustrations.tsFile · 0.85
Icons.tsFile · 0.85
getEventProviderFunction · 0.85
getSharedValuesFunction · 0.85

Calls 1

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…