Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
{
"version": 3,
"sources": ["../../src/getSharedResource.ts"],
"sourcesContent": ["import getSingletonElementInstance from \"./util/getSingletonElementInstance.js\";\n\nconst getMetaDomEl = () => {\n\tconst el = document.createElement(\"meta\");\n\tel.setAttribute(\"name\", \"ui5-shared-resources\");\n\tel.setAttribute(\"content\", \"\"); // attribute \"content\" should be present when \"name\" is set.\n\treturn el;\n};\n\nconst getSharedResourcesInstance = (): Element | null => {\n\tif (typeof document === \"undefined\") {\n\t\treturn null;\n\t}\n\treturn getSingletonElementInstance(`meta[name=\"ui5-shared-resources\"]`, document.head, getMetaDomEl);\n};\n\n/**\n * Use this method to initialize/get resources that you would like to be shared among UI5 Web Components runtime instances.\n * The data will be accessed via a singleton \"ui5-shared-resources\" HTML element in the \"body\" element of the page.\n *\n * @public\n * @param namespace Unique ID of the resource, may contain \".\" to denote hierarchy\n * @param initialValue Object or primitive that will be used as an initial value if the resource does not exist\n * @returns {*}\n */\nconst getSharedResource = (namespace: string, initialValue: T): T => {\n\tconst parts = namespace.split(\".\");\n\tlet current = getSharedResourcesInstance() as Record;\n\n\tif (!current) {\n\t\treturn initialValue;\n\t}\n\n\tfor (let i = 0; i < parts.length; i++) {\n\t\tconst part = parts[i];\n\t\tconst lastPart = i === parts.length - 1;\n\t\tif (!Object.prototype.hasOwnProperty.call(current, part)) {\n\t\t\tcurrent[part] = lastPart ? initialValue : {};\n\t\t}\n\t\tcurrent = current[part];\n\t}\n\n\treturn current as T;\n};\n\nexport default getSharedResource;\n"],
"mappings": "aAAA,OAAOA,MAAiC,wCAExC,MAAMC,EAAe,IAAM,CAC1B,MAAMC,EAAK,SAAS,cAAc,MAAM,EACxC,OAAAA,EAAG,aAAa,OAAQ,sBAAsB,EAC9CA,EAAG,aAAa,UAAW,EAAE,EACtBA,CACR,EAEMC,EAA6B,IAC9B,OAAO,SAAa,IAChB,KAEDH,EAA4B,oCAAqC,SAAS,KAAMC,CAAY,EAY9FG,EAAoB,CAAIC,EAAmBC,IAAuB,CACvE,MAAMC,EAAQF,EAAU,MAAM,GAAG,EACjC,IAAIG,EAAUL,EAA2B,EAEzC,GAAI,CAACK,EACJ,OAAOF,EAGR,QAASG,EAAI,EAAGA,EAAIF,EAAM,OAAQE,IAAK,CACtC,MAAMC,EAAOH,EAAME,CAAC,EACdE,EAAWF,IAAMF,EAAM,OAAS,EACjC,OAAO,UAAU,eAAe,KAAKC,EAASE,CAAI,IACtDF,EAAQE,CAAI,EAAIC,EAAWL,EAAe,CAAC,GAE5CE,EAAUA,EAAQE,CAAI,CACvB,CAEA,OAAOF,CACR,EAEA,eAAeJ",
"names": ["getSingletonElementInstance", "getMetaDomEl", "el", "getSharedResourcesInstance", "getSharedResource", "namespace", "initialValue", "parts", "current", "i", "part", "lastPart"]
}