@abi-software/map-side-bar 2.14.1-simulation.8 → 2.14.2-demo.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,50 +0,0 @@
1
- const resolveURL = (relative, base) => {
2
- const resolved = new URL(relative, base);
3
- return resolved.href;
4
- }
5
-
6
- const readProtocolData = async (item, baseUrl) => {
7
- if (item && item.resource?.url) {
8
- const resolvedUrl = resolveURL(item.resource.url, baseUrl)
9
- const response = await fetch(resolvedUrl)
10
- const data = await response.json()
11
- //convert url
12
- const fields = ["csv_file", "protocol", "thumbnail"]
13
- data.forEach((protocol) => {
14
- fields.forEach((field) => {
15
- if (field in protocol) {
16
- protocol[field] = resolveURL(protocol[field], resolvedUrl)
17
- }
18
- });
19
- })
20
- return data
21
- }
22
-
23
- return
24
- }
25
-
26
- const updateProtocolData = async (entry, baseUrl) => {
27
- if (entry["simulation-protocols"]) {
28
- const processedData = []
29
- for (const item of entry["simulation-protocols"]) {
30
- const data = await readProtocolData(item, baseUrl)
31
- if (data) {
32
- processedData.push(...data)
33
- }
34
- }
35
- return processedData
36
- }
37
- }
38
-
39
- const processProtocolsData = async (results, data, baseUrl) => {
40
- for (const entry of data) {
41
- const protocolData = await updateProtocolData(entry, baseUrl)
42
- entry["protocol-data"] = protocolData
43
- }
44
- results.unshift(...data)
45
- }
46
-
47
- export {
48
- processProtocolsData,
49
- resolveURL,
50
- }