Spaces:
Paused
Paused
File size: 553 Bytes
fb4d8fe | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | export function parseKeyValueOutput(output: string, separator: string): Record<string, string> {
const entries: Record<string, string> = {};
for (const rawLine of output.split(/\r?\n/)) {
const line = rawLine.trim();
if (!line) {
continue;
}
const idx = line.indexOf(separator);
if (idx <= 0) {
continue;
}
const key = line.slice(0, idx).trim().toLowerCase();
if (!key) {
continue;
}
const value = line.slice(idx + separator.length).trim();
entries[key] = value;
}
return entries;
}
|