(rawValue)
| 3 | } |
| 4 | |
| 5 | function parseScalar(rawValue) { |
| 6 | const value = rawValue.trim(); |
| 7 | if (!value) { |
| 8 | return ""; |
| 9 | } |
| 10 | if ( |
| 11 | (value.startsWith("\"") && value.endsWith("\"")) || |
| 12 | (value.startsWith("'") && value.endsWith("'")) |
| 13 | ) { |
| 14 | return value.slice(1, -1); |
| 15 | } |
| 16 | if (value === "true") { |
| 17 | return true; |
| 18 | } |
| 19 | if (value === "false") { |
| 20 | return false; |
| 21 | } |
| 22 | if (value === "null") { |
| 23 | return null; |
| 24 | } |
| 25 | if (/^-?\d+(\.\d+)?$/.test(value)) { |
| 26 | return Number(value); |
| 27 | } |
| 28 | if (value.startsWith("[") && value.endsWith("]")) { |
| 29 | return value |
| 30 | .slice(1, -1) |
| 31 | .split(",") |
| 32 | .map((item) => item.trim()) |
| 33 | .filter(Boolean) |
| 34 | .map(parseScalar); |
| 35 | } |
| 36 | return value; |
| 37 | } |
| 38 | |
| 39 | function nextMeaningfulIndex(lines, startIndex) { |
| 40 | for (let index = startIndex; index < lines.length; index += 1) { |
no test coverage detected