MCPcopy Create free account
hub / github.com/openai/plugins / parseScalar

Function parseScalar

plugins/plugin-eval/src/lib/frontmatter.js:5–37  ·  view source on GitHub ↗
(rawValue)

Source from the content-addressed store, hash-verified

3}
4
5function 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
39function nextMeaningfulIndex(lines, startIndex) {
40 for (let index = startIndex; index < lines.length; index += 1) {

Callers 1

parseBlockFunction · 0.85

Calls 2

mapMethod · 0.80
filterMethod · 0.80

Tested by

no test coverage detected