aboutsummaryrefslogtreecommitdiffstats
path: root/sdnr/wt/odlux/apps/configurationApp/src/services/yangService.ts
diff options
context:
space:
mode:
Diffstat (limited to 'sdnr/wt/odlux/apps/configurationApp/src/services/yangService.ts')
-rw-r--r--sdnr/wt/odlux/apps/configurationApp/src/services/yangService.ts34
1 files changed, 14 insertions, 20 deletions
diff --git a/sdnr/wt/odlux/apps/configurationApp/src/services/yangService.ts b/sdnr/wt/odlux/apps/configurationApp/src/services/yangService.ts
index b81a92c14..bbd051aeb 100644
--- a/sdnr/wt/odlux/apps/configurationApp/src/services/yangService.ts
+++ b/sdnr/wt/odlux/apps/configurationApp/src/services/yangService.ts
@@ -16,28 +16,22 @@
* ============LICENSE_END==========================================================================
*/
-type YangInfo = [string, (string | null | undefined)];
+const cache: { [path: string]: string } = { };
+const getCapability = async (capability: string, nodeId: string, version?: string) => {
+ const url = `/yang-schema/${capability}${version ? `/${version}` : ''}?node=${nodeId}`;
-const cache: { [path: string]: string } = {
+ const cacheHit = cache[url];
+ if (cacheHit) return cacheHit;
-};
-
-class YangService {
-
- public async getCapability(capability: string, nodeId: string, version?: string) {
- const url = `/yang-schema/${capability}${version ? `/${version}` : ""}?node=${nodeId}`;
-
- const cacheHit = cache[url];
- if (cacheHit) return cacheHit;
-
- const res = await fetch(url);
- const yangFile = res.ok && (await res.text());
- if (yangFile !== false && yangFile !== null) {
- cache[url] = yangFile;
- }
- return yangFile;
+ const res = await fetch(url);
+ const yangFile = res.ok && (await res.text());
+ if (yangFile !== false && yangFile !== null) {
+ cache[url] = yangFile;
}
-}
+ return yangFile;
+};
-export const yangService = new YangService();
+export const yangService = {
+ getCapability,
+};
export default yangService; \ No newline at end of file