MCPcopy Index your code
hub / github.com/Doorman11991/smallcode / parseTomlConfig

Function parseTomlConfig

bin/config.js:110–131  ·  view source on GitHub ↗
(content)

Source from the content-addressed store, hash-verified

108}
109
110function parseTomlConfig(content) {
111 const out = {};
112 let section = [];
113 for (const rawLine of content.split('\n')) {
114 const line = rawLine.trim();
115 if (!line || line.startsWith('#')) continue;
116 const sectionMatch = line.match(/^\[([^\]]+)\]$/);
117 if (sectionMatch) {
118 section = sectionMatch[1].split('.').map(s => s.trim()).filter(Boolean);
119 continue;
120 }
121 const kv = line.match(/^([A-Za-z0-9_-]+)\s*=\s*(.+)$/);
122 if (!kv) continue;
123 let cursor = out;
124 for (const part of section) {
125 if (!cursor[part] || typeof cursor[part] !== 'object') cursor[part] = {};
126 cursor = cursor[part];
127 }
128 cursor[kv[1]] = parseTomlValue(kv[2]);
129 }
130 return out;
131}
132
133function coerceModelEntry(value) {
134 if (!value) return {};

Callers 1

loadConfigFunction · 0.85

Calls 1

parseTomlValueFunction · 0.85

Tested by

no test coverage detected