MCPcopy Index your code
hub / github.com/devgutt/wdr-render-basic / processHyperdata

Function processHyperdata

src/Hyperdata.js:3–32  ·  view source on GitHub ↗
(dataManager, str)

Source from the content-addressed store, hash-verified

1'use strict';
2
3async function processHyperdata(dataManager, str) {
4 const reg = /([\\]?){{\ *(?:\[([^{}]+)\]\ *)?([^{}]+)\ *}}/g;
5
6 const ret = [];
7 let match;
8 let i = 0;
9 while ((match = reg.exec(str)) !== null) {
10
11 const opr = match[1];
12
13 ret.push(str.slice(i, match.index));
14
15 if (opr !== '\\') {
16 const url = match[2];
17 const path = match[3];
18 try {
19 ret.push(await getValue(dataManager, url, path));
20 } catch (error) {
21 ret.push("[ERROR]");
22 }
23 } else {
24 ret.push((match[0] + "").slice(1));
25 }
26
27 i = reg.lastIndex;
28 }
29 ret.push(str.slice(i));
30
31 return ret.join("");
32}
33
34async function getValue(dataManager, url, path) {
35

Callers

nothing calls this directly

Calls 1

getValueFunction · 0.85

Tested by

no test coverage detected