(dataManager, str)
| 1 | 'use strict'; |
| 2 | |
| 3 | async 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 | |
| 34 | async function getValue(dataManager, url, path) { |
| 35 |
nothing calls this directly
no test coverage detected